Skip to content

Instantly share code, notes, and snippets.

@lmosele
Created February 2, 2017 20:09
Show Gist options
  • Save lmosele/72936ab99533831dda4038395bd32fd3 to your computer and use it in GitHub Desktop.
Save lmosele/72936ab99533831dda4038395bd32fd3 to your computer and use it in GitHub Desktop.
Hash URL tracking in Google Analytics attempt
// 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