Skip to content

Commit

Permalink
Add piwik snippet to analytics.html
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoJokhan committed Dec 4, 2023
1 parent 4133a2c commit de9717b
Showing 1 changed file with 90 additions and 29 deletions.
119 changes: 90 additions & 29 deletions packages/cms/views/partials/analytics.html
@@ -1,35 +1,96 @@
{# --- Google old style --- #}
{% if data.global.analyticsType == 'google-analytics-old-style' %}
{% if data.cookieConsent %}
{# --- Google old style --- #} {% if data.global.analyticsType ==
'google-analytics-old-style' %} {% if data.cookieConsent %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
(i[r] =
i[r] ||
function () {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(
window,
document,
'script',
'https://www.google-analytics.com/analytics.js',
'ga'
);

ga('create', '{{data.global.analyticsIdentifier}}', 'auto');
ga('send', 'pageview');
ga('create', '{{data.global.analyticsIdentifier}}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
{% endif %}

{# --- Google new style --- #}
{% if data.global.analyticsType == 'google-analytics-new-style' %}
{% if data.cookieConsent %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{data.global.analyticsIdentifier}}"></script>
{% endif %} {% endif %} {# --- Google new style --- #} {% if
data.global.analyticsType == 'google-analytics-new-style' %} {% if
data.cookieConsent %}
<script
async
src="https://www.googletagmanager.com/gtag/js?id={{data.global.analyticsIdentifier}}"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{data.global.analyticsIdentifier}}');
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '{{data.global.analyticsIdentifier}}');
</script>
{% endif %}
{% endif %}

{# --- Custom code --- #}
{% if data.global.analyticsType == 'custom' %}
{% if data.cookieConsent %}
{{data.global.analyticsCodeBlock | safe}}
{% endif %}
{% endif %}
{% endif %} {% endif %} {# --- Custom code --- #} {% if
data.global.analyticsType == 'custom' %} {% if data.cookieConsent %}
{{data.global.analyticsCodeBlock | safe}} {% endif %} {% endif %}

<script type="text/javascript">
(function (window, document, dataLayerName, id) {
(window[dataLayerName] = window[dataLayerName] || []),
window[dataLayerName].push({
start: new Date().getTime(),
event: 'stg.start',
});
var scripts = document.getElementsByTagName('script')[0],
tags = document.createElement('script');
function stgCreateCookie(a, b, c) {
var d = '';
if (c) {
var e = new Date();
e.setTime(e.getTime() + 24 * c * 60 * 60 * 1e3),
(d = '; expires=' + e.toUTCString());
}
document.cookie = a + '=' + b + d + '; path=/';
}
var isStgDebug =
(window.location.href.match('stg_debug') ||
document.cookie.match('stg_debug')) &&
!window.location.href.match('stg_disable_debug');
stgCreateCookie('stg_debug', isStgDebug ? 1 : '', isStgDebug ? 14 : -1);
var qP = [];
dataLayerName !== 'dataLayer' &&
qP.push('data_layer_name=' + dataLayerName),
isStgDebug && qP.push('stg_debug');
var qPString = qP.length > 0 ? '?' + qP.join('&') : '';
(tags.async = !0),
(tags.src =
'https://dap.amsterdam.nl/containers/' + id + '.js' + qPString),
scripts.parentNode.insertBefore(tags, scripts);
!(function (a, n, i) {
a[n] = a[n] || {};
for (var c = 0; c < i.length; c++)
!(function (i) {
(a[n][i] = a[n][i] || {}),
(a[n][i].api =
a[n][i].api ||
function () {
var a = [].slice.call(arguments, 0);
'string' == typeof a[0] &&
window[dataLayerName].push({
event: n + '.' + i + ':' + a[0],
parameters: [].slice.call(arguments, 1),
});
});
})(i[c]);
})(window, 'ppms', ['tm', 'cm']);
})(window, document, 'dataLayer', 'e63312c0-0efe-4c4f-bba1-3ca1f05374a8');
</script>

1 comment on commit de9717b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published new image: openstad/frontend:feature-piwik-integration-de9717b

Please sign in to comment.