mgonto / angularytics

The solution to tracking page views and events in a SPA with AngularJS
MIT License
630 stars 70 forks source link

Track events to the active Page #3

Closed saschanowak closed 11 years ago

saschanowak commented 11 years ago

If you have a SPA you want to track events to the actual pageView for better filtering in analytics. For Example: If you track the login button with a custom event and want to know on which page the user press it, you can't filter it because it gets always tracked on the first pageView.

The problem is that actual events will not be associated with virtual pages.

But i found a litte hacky solution on the web when I implemented the tracking for one of our customers:

Replace:

_gaq.push(['_trackPageview', url]);

with:

_gaq.push(['_set', 'page', url]);
_gaq.push(['_set', 'title', document.title]);
_gaq.push(['_trackPageview']);

I hope I could help with that.

Greetings Sascha

mgonto commented 11 years ago

Hey,

Thanks for the input!!

So, you say that the _trackPageview will not receive an URL now, is that intentional? Will it use the one set in page ??

I'll add this!

saschanowak commented 11 years ago

This article explain the problem in a much better way then I did ;)

http://www.e-nor.com/blog/google-analytics/reporting-accurate-funnels-in-google-analytics

mgonto commented 11 years ago

Understood, I'll implement this!