Last active
October 3, 2018 04:55
-
-
Save bakoushin/b59db12d32e5e68328615c1d5acce5e8 to your computer and use it in GitHub Desktop.
Tweak to make InVision prototype work with Google Analytics
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
<!-- Tweak for Google Analytics to catch SPA navigation --> | |
<script> | |
var currentPage = window.location.href; | |
window.onload = function() { | |
setInterval(function() { | |
if (currentPage !== window.location.href) { | |
currentPage = window.location.href; | |
var newPage = window.location.pathname + window.location.hash | |
ga('set', 'page', newPage); | |
ga('send', 'pageview'); | |
console.log(newPage); | |
} | |
}, 100); | |
}; | |
</script> | |
<!-- End of tweak for Google Analytics to catch SPA navigation --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment