xref: /webtrees/resources/views/modules/google-analytics/snippet-v4.phtml (revision f9f6fffde9a4ddea74e52e0f4c13cde4ec13f3a4)
1*f9f6fffdSGreg Roach<?php
2*f9f6fffdSGreg Roach
3*f9f6fffdSGreg Roachdeclare(strict_types=1);
4*f9f6fffdSGreg Roach
5*f9f6fffdSGreg Roach/**
6*f9f6fffdSGreg Roach * @var string $access_level
7*f9f6fffdSGreg Roach * @var string $tree_name
8*f9f6fffdSGreg Roach * @var string $GOOGLE_ANALYTICS_ID
9*f9f6fffdSGreg Roach */
10*f9f6fffdSGreg Roach?>
11*f9f6fffdSGreg Roach<script async src="https://www.googletagmanager.com/gtag/js?id=<?=  e($GOOGLE_ANALYTICS_ID ?? '') ?>"></script>
12*f9f6fffdSGreg Roach<script>
13*f9f6fffdSGreg Roach  window.dataLayer = window.dataLayer || [];
14*f9f6fffdSGreg Roach  function gtag(){dataLayer.push(arguments);}
15*f9f6fffdSGreg Roach  gtag('js', new Date());
16*f9f6fffdSGreg Roach  gtag('config', <?= json_encode($GOOGLE_ANALYTICS_ID, JSON_THROW_ON_ERROR) ?>, {
17*f9f6fffdSGreg Roach    'custom_map': {'dimension1': 'tree_name', 'dimension2': 'access_level'},
18*f9f6fffdSGreg Roach    'tree_name': <?= json_encode($tree_name, JSON_THROW_ON_ERROR) ?>,
19*f9f6fffdSGreg Roach    'access_level': <?= json_encode($access_level, JSON_THROW_ON_ERROR) ?>,
20*f9f6fffdSGreg Roach  });
21*f9f6fffdSGreg Roach</script>
22