It’s surprisingly simple to use Google Analytics for Tracking Hash URLs really. I needed to track each “page” as it was viewed, but being a hash url driven website of course google analytics (by default) only recognises the “index”, seeing as its essentially a “one page website”. No good to anyone…
So a simple one liner ( i have added this inside my function that loads the content, but it goes wherever you need to track)
[code]
_gaq.push([‘_trackPageview’, "/" + window.location.hash]);
[/code]
Looking at the Google Analytics screen we can now see each hash url logged as a visited page. Exactly what the client wants to see.
I am trying to accomplish this in the yoast wordpress plugin. I tried this but I do not think it is working correctly, any ideas?
line:244 class-frontend.php
else {
$push[] = "'_trackPageview', + window.location.hash";
}