First attempt to make GA track URL fragments
This commit is contained in:
parent
d284b3d3b4
commit
358deb9ea4
|
@ -1,9 +1,21 @@
|
|||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-57641651-4"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
<!--<!– Global site tag (gtag.js) - Google Analytics –>-->
|
||||
<!--<script async src="https://www.googletagmanager.com/gtag/js?id=UA-57641651-4"></script>-->
|
||||
<!--<script>-->
|
||||
<!--window.dataLayer = window.dataLayer || [];-->
|
||||
<!--function gtag(){dataLayer.push(arguments);}-->
|
||||
<!--gtag('js', new Date());-->
|
||||
|
||||
gtag('config', 'UA-57641651-4');
|
||||
<!--gtag('config', 'UA-57641651-4');-->
|
||||
<!--</script>-->
|
||||
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-57641651-4', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
<!-- End Google Analytics -->
|
|
@ -31,9 +31,13 @@ $(document).ready(function(){
|
|||
$('.sidenav').sidenav();
|
||||
|
||||
$('.sidenav > li > a').click(function(event){
|
||||
|
||||
event.preventDefault();//stop browser to take action for clicked anchor
|
||||
|
||||
let replace = $(this).text().trim().replace(/\s+/g, '-');
|
||||
console.log(replace);
|
||||
ga('set', 'page', replace);
|
||||
ga('send', 'pageview');
|
||||
|
||||
location.hash = event.target.hash;
|
||||
|
||||
//get displaying tab content jQuery selector
|
||||
|
@ -73,3 +77,4 @@ if ('serviceWorker' in navigator) {
|
|||
console.log("Error registering service worker" + e);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue