-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (61 loc) · 2.31 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!doctype html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>DataLayer sync</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
<!-- Matomo Tag Manager -->
<script>
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://matomo.example.com/js/container_XXXXXXXX.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Tag Manager -->
</head>
<body>
<section class="py-5">
<div class="container">
<h1>Demo DataLayer</h1>
<br>
<button class="btn btn-primary" onclick="seedDataLayer()">Click me</button>
</div>
</section>
<script>
/**** COPY FROM HERE ****/
window.dataLayer = window.dataLayer || [];
window._mtm = window._mtm || [];
let syncDataLayer = function(array, callback) {
array.push = function(e) {
Array.prototype.push.call(array, e);
callback(array);
};
};
syncDataLayer(window.dataLayer, function(e) {
window._mtm.push(window.dataLayer[window.dataLayer.length-1]);
});
/**** TO HERE ****/
function seedDataLayer() {
dataLayer.push({
'event': 'demo',
'data': {
'first': 1,
'second': 2
}
})
}
</script>
</body>
</html>