Created
February 2, 2017 20:09
-
-
Save lmosele/72936ab99533831dda4038395bd32fd3 to your computer and use it in GitHub Desktop.
Hash URL tracking in Google Analytics attempt
This file contains 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
// This sort of works, but not really. | |
function sendAnalytics() { | |
var pageName = location.hash.replace('#', ''); | |
ga('send', 'screenview', { | |
'page': location.pathname + location.search + location.hash, | |
'screenName': 'member ' + pageName + ' page' | |
}); | |
} | |
window.addEventListener('hashchange', function() { | |
sendAnalytics(); | |
}); | |
//OR | |
window.onhashchange = sendAnalytics; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment