Skip to content
This repository was archived by the owner on Jun 25, 2024. It is now read-only.

Commit a06453f

Browse files
author
Baggerone
authored
Merge pull request #120 from silinternational/develop
Release 8.0.0 Use new Google Analytics 4 script
2 parents 5893726 + 94d54f1 commit a06453f

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The login page looks for `/simplesamlphp/www/logo.png` which is **NOT** provided
3636
Update `/simplesamlphp/config/config.php`:
3737

3838
```
39-
'analytics.trackingId' => 'UA-some-unique-id-for-your-site'
39+
'analytics.trackingId' => 'G-some-unique-id-for-your-site'
4040
```
4141

4242
_[ssp-base](https://github.com/silinternational/ssp-base) provides a convenience by loading this config with whatever is in the environment variable `ANALYTICS_ID`._

themes/material/common-head-elements.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,19 @@
99
$trackingId = htmlentities($this->configuration->getValue('analytics.trackingId'));
1010
if (! empty($trackingId)) {
1111
?>
12+
<!-- Google tag (gtag.js) -->
13+
<script async src="https://www.googletagmanager.com/gtag/js?id=<?= $trackingId ?>"></script>
1214
<script>
13-
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
14-
ga('create', '<?= $trackingId ?>', 'auto');
15-
ga('send', 'pageview');
16-
</script>
17-
<script async src='https://www.google-analytics.com/analytics.js'></script>
18-
<?php
19-
} else {
20-
?>
21-
<script>
22-
window.ga = function () {
23-
// Null object pattern to avoid `if (window.ga)` wherever ga is used.
24-
}
15+
window.dataLayer = window.dataLayer || [];
16+
function gtag(){dataLayer.push(arguments);}
17+
gtag('js', new Date());
18+
19+
gtag('config', '<?= $trackingId ?>');
2520
</script>
2621
<?php
2722
}
2823
?>
2924

30-
3125
<?php
3226
$colors = htmlentities($this->configuration->getValue('theme.color-scheme') ?: 'indigo-purple');
3327
?>

0 commit comments

Comments
 (0)