Reputation: 3358
I have a long single page website using hashtags in the URL when you get to a certain section from scrolling or clicking. What technique can I use to track these hashtags as "pages" in google analytics?
Upvotes: 4
Views: 5576
Reputation: 2214
Yeah, virtual pageviews is your solution, here's the tutorial: http://services.google.com/analytics/breeze/en/et_vps/index.html
Upvotes: 3
Reputation: 37305
(Recycling from a prior answer...)
Generically, your code could look like this:
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
You could either bind that code to every time you have a hash change within your application, or you could use a generic hashchange plugin, that uses the HTML5 onhashchange, and some backwards compatible hacks for older browsers, and bind this code to that event, so that it fires every time your hash changes.
Using that plugin, your code could look like:
$(window).hashchange( function(){
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
})
Upvotes: 8
Reputation: 171
I believe you can use google analytics something like this
onclick="javascript:_gaq.push(['_trackPageview','/PDF/EXAMPLE PDF NAME']);"
in your google analytics it will then record a click in the folder structure you specify
Upvotes: 0