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