Question

I would like to know if Google Analytics automatically keeps track of the pages that have their state retained using the ajax history token ('#'), developed for example with GWT. My app has a single html page and different modules (pages) have the same URL, except that part that comes after # (ex. www.mysite.com?test=true#page=Contacts/id=1).

Also, if this mentioned behavior is not by default, is there a way to set up the Google Analyics to have this functionality ?

EDIT:

I found this article which explains how #hashtag can be tracked: http://www.searchenginepeople.com/blog/how-to-track-clicks-on-anchors-in-google-analytics.html

But, if i use this solution, will the page access be recorded when a user presses an Anchor with href'#hastag' or only when a a page is accessed directly with that hashtag (in that case, I should register a function that calls trackPageview when history changes)?

Was it helpful?

Solution 2

I added the following lines to the initial analytics script:

_gaq.push(['_trackPageview', location.pathname + location.search + location.hash]);

and

window.onhashchange =  function(){            
                _gaq.push(['_trackPageview',location.pathname + location.search  + location.hash]);             
            }

which tracks the history change.

OTHER TIPS

Google tracks the # just fine. You just need to take it actually receives the # as-is (in our case the # got url-encoded to %23 and we had to use a search-and-replace-filter to restore it).

The most elegant way would be probably to look in GA admin into the instructions for the advanced filter - there is a nice example how to rewrite obscure URls into something readable by humans in the reports, which could be easily adapted for your needs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top