|
1 | 1 | {% if GOOGLEANALYTICS_ID %} |
2 | | - {# 0 = Legacy (analytics.js) - Google Analytics #} |
3 | | - {# 1 = Global site tag (gtag.js) - Google Analytics #} |
4 | | - {% if GOOGLEANALYTICS_TAG == 1 %} |
5 | | - <!-- Global site tag (gtag.js) - Google Analytics --> |
6 | | - <script async src="https://www.googletagmanager.com/gtag/js?id={{ GOOGLEANALYTICS_ID }}"></script> |
7 | | - <script> |
8 | | - window.dataLayer = window.dataLayer || []; |
9 | | - function gtag(){dataLayer.push(arguments);} |
10 | | - gtag('js', new Date()); |
| 2 | + <!-- Google tag (gtag.js) - Google Analytics --> |
| 3 | + <script{% if S_CONSENTMANAGER_ANALYTICS_ENABLED %} type="text/plain" data-consent-category="analytics"{% endif %} async src="https://www.googletagmanager.com/gtag/js?id={{ GOOGLEANALYTICS_ID }}"></script> |
| 4 | + <script{% if S_CONSENTMANAGER_ANALYTICS_ENABLED %} type="text/plain" data-consent-category="analytics"{% endif %}> |
| 5 | + window.dataLayer = window.dataLayer || []; |
| 6 | + function gtag(){dataLayer.push(arguments);} |
| 7 | + gtag('js', new Date()); |
11 | 8 |
|
12 | | - gtag('config', '{{ GOOGLEANALYTICS_ID }}', { |
13 | | - {%- EVENT phpbb_googleanalytics_gtag_options -%} |
14 | | - {%- if S_REGISTERED_USER %}'user_id': '{{ GOOGLEANALYTICS_USER_ID }}',{% endif -%} |
15 | | - {%- if S_ANONYMIZE_IP %}'anonymize_ip': true,{% endif -%} |
16 | | - {%- if S_COOKIE_SECURE -%}'cookie_flags': 'samesite=none;secure',{%- endif -%} |
17 | | - }); |
18 | | - </script> |
19 | | - {% else %} |
20 | | - <script> |
21 | | - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
22 | | - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
23 | | - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
24 | | - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
25 | | - |
26 | | - ga('create', '{{ GOOGLEANALYTICS_ID }}', 'auto'); |
27 | | - {% if S_REGISTERED_USER %}ga('set', 'userId', {{ GOOGLEANALYTICS_USER_ID }});{% endif %} |
28 | | - {% if S_ANONYMIZE_IP %}ga('set', 'anonymizeIp', true);{% endif %} |
29 | | - {% EVENT phpbb_googleanalytics_alter_ga_requirements -%} |
30 | | - ga('send', 'pageview'); |
31 | | - </script> |
32 | | - {% endif %} |
| 9 | + gtag('config', '{{ GOOGLEANALYTICS_ID }}', { |
| 10 | + {%- EVENT phpbb_googleanalytics_gtag_options -%} |
| 11 | + {%- if S_REGISTERED_USER %}'user_id': '{{ GOOGLEANALYTICS_USER_ID }}',{% endif -%} |
| 12 | + {%- if S_ANONYMIZE_IP %}'anonymize_ip': true,{% endif -%} |
| 13 | + {%- if S_COOKIE_SECURE -%}'cookie_flags': 'samesite=none;secure',{%- endif -%} |
| 14 | + }); |
| 15 | + </script> |
33 | 16 | {% endif %} |
0 commit comments