Jump to content

Recommended Posts

Posted

Hi,

i want to build a simple tracking system, where i can see how the users navigate through my site.

Right now i insert a row in a custom db-table with a unique id, the page a user visits, the page the user came and a timestamp. I do this with a after-hook to »ProcessPageView:finished«, which is setup in an _init.php template which is prepend to any other template.

This works fine.

The problem is that this doesn't work on cached templates/pages.

How can I use the template-cache-feature AND update my db-table via this hook or any other technique?

Thanks!

Posted

Ajax-call?

simplified:

<script type='text/javascript'>
	$(document).ready(function() {
		$.get( "/my/ajax/url/", { id: "1234" } );
	});
</script>
  • Like 1
Posted

Yes, I thought about ajax, but I do not like the detour. This way i have to send all the needed data (page-id, referer, action, submitted form etc.) via ajax.

I hoped for a better way (e.g. a hook, which get's called regardless of cache) to do this.

Is there a better way to setup this hook, instead if doing this in a template?

Posted

Which caching method are you using? If it's ProCache then PHP and mySQL aren't available so AJAX is the only alternative there.

Posted

Such calls should never been put in the init.php (well you have to be careful). If you use render inside your template to render partials for example the init will get called each time.

Anyway you should add your hook in a autoload module. See HelloWorld.module.

Posted

yeah, i realized, that this was a bad idea.

right now, i'm working on a module based on the lazycron.module, which seems to also work with cached pages/templates.

so i think, i found my solution. thanks!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...