Skip to content

Instantly share code, notes, and snippets.

@bakoushin
Last active October 3, 2018 04:55
Show Gist options
  • Save bakoushin/b59db12d32e5e68328615c1d5acce5e8 to your computer and use it in GitHub Desktop.
Save bakoushin/b59db12d32e5e68328615c1d5acce5e8 to your computer and use it in GitHub Desktop.
Tweak to make InVision prototype work with Google Analytics
<!-- 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