|
- <?php
-
- // To use this script, please fill in your Google Analytics ID below
- $GoogleAnalyticsId = 'UA-XXXXX-X';
-
- // DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!
- if ('UA-XXXXX-X' != $GoogleAnalyticsId && !BE_USER_LOGGED_IN && !$this->hasAuthenticatedBackendUser()): ?>
-
- <script>
-
- function initGoogleAnalytics()
- {
- (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', '<?= $GoogleAnalyticsId ?>', 'auto');
- ga('set', 'anonymizeIp', true);
- ga('send', 'pageview');
- }
-
- cookieName = 'FZ_COOKIECONSENT'
- for (let level = 3; level <= 3; level ++)
- {
- if(localStorage.getItem(cookieName + '_' + level) && localStorage.getItem(cookieName + '_' + level) > Math.round(Date.now() / 1000))
- {
- initGoogleAnalytics();
- console.log('google analytics init')
- break;
- }
- }
-
- jQuery(document).on('user_privacy_changed',function(event,params)
- {
- if(params.level >= 3)
- {
- initGoogleAnalytics();
- console.log('google analytics init via event');
- }
- });
- </script>
-
- <?php endif; ?>
|