|
1 | 1 | {% if site.google_analytics_ua %} |
2 | 2 | <!-- Google Analytics --> |
| 3 | +<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_ua }}"></script> |
3 | 4 | <script> |
4 | | - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
5 | | - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
6 | | - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
7 | | - })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
8 | | - ga('create', '{{ site.google_analytics_ua }}', 'auto'); |
| 5 | + window.dataLayer = window.dataLayer || []; |
| 6 | + function gtag() { dataLayer.push(arguments); } |
| 7 | + gtag('js', new Date()); |
9 | 8 |
|
10 | | - // anonymize user IPs (chops off the last IP triplet) |
11 | | - ga('set', 'anonymizeIp', true); |
12 | | - ga('set', 'forceSSL', true); |
13 | | - ga('send', 'pageview'); |
| 9 | + // `forceSSL` was used for analytics.js (the older Google Analytics script). It isn't documented for gtag.js, but the term occurs in the gtag.js code; figure it doesn't hurt to leave it in. -@afeld, 5/29/19 |
| 10 | + gtag('config', '{{ site.google_analytics_ua }}', { 'anonymize_ip': true, 'forceSSL': true }); |
14 | 11 | </script> |
15 | 12 | {% endif %} |
16 | 13 |
|
|
0 commit comments