diff options
author | Justin Phelps <juphelps@netflix.com> | 2021-10-14 20:34:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 20:34:06 +0300 |
commit | 94143e0e42a566f75aedb7f93f62251fa43ff414 (patch) | |
tree | d58df8b4f47744acf5c348f27dc644e228da6996 | |
parent | 28dd49a697badd2564fa5352aeafe85a85db5fac (diff) |
Update Google Analytics code to the new Global site tag (#126)
-rw-r--r-- | layouts/partials/google_analytics.html | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/layouts/partials/google_analytics.html b/layouts/partials/google_analytics.html index e3b83a9..083e945 100644 --- a/layouts/partials/google_analytics.html +++ b/layouts/partials/google_analytics.html @@ -1,14 +1,15 @@ {{ with .Site.Params.googleAnalytics }} + +<!-- Global site tag (gtag.js) - Google Analytics --> +<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script> <script> // Never report traffic that originates from local testing. if (window.location.hostname != "localhost") { - (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','//www.google-analytics.com/analytics.js','ga'); - - ga('create', '{{ . }}', 'auto'); - ga('send', 'pageview'); + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', '{{ . }}'); } </script> + {{ end }} |