|
7 | 7 |
|
8 | 8 | <?php |
9 | 9 | $trackingId = htmlentities($this->configuration->getValue('analytics.trackingId')); |
10 | | - |
11 | 10 | if (! empty($trackingId)) { |
12 | | -?> |
13 | | - <script> |
14 | | - window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; |
15 | | - ga('create', '<?= $trackingId ?>', 'auto'); |
16 | | - ga('send', 'pageview'); |
17 | | - </script> |
18 | | - <script async src='https://www.google-analytics.com/analytics.js'></script> |
19 | | -<?php |
20 | | -} else { |
21 | | -?> |
22 | | - <script> |
23 | | - window.ga = function () { |
24 | | - // Null object pattern to avoid `if (window.ga)` wherever ga is used. |
25 | | - } |
26 | | - </script> |
27 | | -<?php |
28 | | -} |
29 | | -?> |
30 | | - |
31 | | -<?php |
32 | | -// This block of code is intended to replace the old window.ga code (above) once |
33 | | -// the transition from Google's Universal Analytics to GA4 type projects has been completed |
34 | | -$trackingIdGA4 = htmlentities($this->configuration->getValue('analytics.trackingIdGA4')); |
35 | | -if (! empty($trackingIdGA4)) { |
36 | 11 | ?> |
37 | 12 | <!-- Google tag (gtag.js) --> |
38 | | - <script async src="https://www.googletagmanager.com/gtag/js?id=<?= $trackingIdGA4 ?>"></script> |
| 13 | + <script async src="https://www.googletagmanager.com/gtag/js?id=<?= $trackingId ?>"></script> |
39 | 14 | <script> |
40 | 15 | window.dataLayer = window.dataLayer || []; |
41 | 16 | function gtag(){dataLayer.push(arguments);} |
42 | 17 | gtag('js', new Date()); |
43 | 18 |
|
44 | | - gtag('config', '<?= $trackingIdGA4 ?>'); |
45 | | - </script> |
46 | | -<?php |
47 | | -} else { |
48 | | -?> |
49 | | - <script> |
50 | | - window.dataLayer = function () { |
51 | | - // Null object pattern to avoid `if (window.dataLayer)` wherever dataLayer is used. |
52 | | - } |
| 19 | + gtag('config', '<?= $trackingId ?>'); |
53 | 20 | </script> |
54 | 21 | <?php |
55 | 22 | } |
56 | 23 | ?> |
57 | 24 |
|
58 | | - |
59 | 25 | <?php |
60 | 26 | $colors = htmlentities($this->configuration->getValue('theme.color-scheme') ?: 'indigo-purple'); |
61 | 27 | ?> |
|
0 commit comments