Last active
August 29, 2015 14:18
-
-
Save franklin-like-the-turtle/da1ac18999b15994948f to your computer and use it in GitHub Desktop.
Hashchanges as Pageviews in UA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//adds verified JS route to gaCrumb for initial pageview report | |
if(window.location.hash.indexOf('#/') !== -1){ | |
gaCrumb = gaCrumb + '/' + window.location.hash; | |
} | |
//fires verified JS route as additional "virtual pageview" | |
$(window).hashchange(function(){ | |
if(window.location.hash.indexOf('#/') > -1){ | |
if(gaCrumb.indexOf('#') > -1){ | |
gaCrumb = gaCrumb.split('#')[0]; | |
} | |
ga('send', 'pageview', gaCrumb + '/' + window.location.hash); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment