|
1 | 1 | {% if GOOGLEANALYTICS_ID %} |
2 | | -<script> |
3 | | - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
4 | | - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
5 | | - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
6 | | - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
| 2 | + <!-- https://developers.google.com/analytics/devguides/collection/gtagjs/migration --> |
| 3 | + <!-- Global site tag (gtag.js) - Google Analytics --> |
| 4 | + <script async src="https://www.googletagmanager.com/gtag/js?id={{ GOOGLEANALYTICS_ID }}"></script> |
| 5 | + <script> |
| 6 | + window.dataLayer = window.dataLayer || []; |
| 7 | + function gtag(){dataLayer.push(arguments);} |
| 8 | + gtag('js', new Date()); |
7 | 9 |
|
8 | | - ga('create', '{{ GOOGLEANALYTICS_ID }}', 'auto'); |
9 | | - {% if S_REGISTERED_USER -%} |
10 | | - ga('set', 'userId', {{ GOOGLEANALYTICS_USER_ID }}); |
11 | | - {% endif -%} |
12 | | - {% if S_ANONYMIZE_IP -%} |
13 | | - ga('set', 'anonymizeIp', true); |
14 | | - {% endif -%} |
15 | | - {% EVENT phpbb_googleanalytics_alter_ga_requirements -%} |
16 | | - ga('send', 'pageview'); |
17 | | -</script> |
| 10 | + gtag('config', '{{ GOOGLEANALYTICS_ID }}', { |
| 11 | + {% EVENT phpbb_googleanalytics_gtag_options %} |
| 12 | + {% if S_REGISTERED_USER %}'user_id': '{{ GOOGLEANALYTICS_USER_ID }}',{% endif %} |
| 13 | + {% if S_ANONYMIZE_IP %}'anonymize_ip': true,{% endif %} |
| 14 | + }); |
| 15 | + </script> |
18 | 16 | {% endif %} |
0 commit comments