Skip to content

Commit

Permalink
Migrate from analytics.js to gtag.js (#281)
Browse files Browse the repository at this point in the history
* Replace analytics.js with gtag.js
  • Loading branch information
mladenilic authored and DirtyF committed Oct 29, 2018
1 parent b5df2ee commit 64c6b7a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions _includes/google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
if(!(window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1")) {
(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');
window['ga-disable-{{ site.google_analytics }}'] = window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1";
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
}
gtag('config', '{{ site.google_analytics }}');
</script>

0 comments on commit 64c6b7a

Please sign in to comment.