Skip to content

Commit

Permalink
Update to use gtag for GA4
Browse files Browse the repository at this point in the history
  • Loading branch information
xcompass committed Jul 25, 2022
1 parent f1027c1 commit 0bb19ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
19 changes: 9 additions & 10 deletions compair/templates/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,15 @@
})();
</script>
{% if ga_tracking_id %}
<!-- Google Analytics -->
<script type="text/javascript">
(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', '{{ ga_tracking_id }}', 'auto');
ga('send', 'pageview');
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ ga_tracking_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ ga_tracking_id }}');
</script>>
{% endif %}
</head>
<body>
Expand Down
17 changes: 8 additions & 9 deletions compair/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,15 @@
})();
</script>
{% if ga_tracking_id %}
<!-- Google Analytics -->
<script type="text/javascript">
(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');
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ ga_tracking_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

ga('create', '{{ ga_tracking_id }}', 'auto');
ga('send', 'pageview');
</script>
gtag('config', '{{ ga_tracking_id }}');
</script>>
{% endif %}
</head>
<body>
Expand Down

0 comments on commit 0bb19ce

Please sign in to comment.