Created
February 13, 2020 05:54
-
-
Save webtoffee-git/25b467f4309e0aeaca206de18e1695c3 to your computer and use it in GitHub Desktop.
Javascript helper function for script blocking( Hotjar , Google Analytics ) - using WebToffee GDPR Cookie Consent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| function CookieLawInfo_Accept_Callback() | |
| { | |
| if (CLI.consent.non_necessary) | |
| { | |
| // Hotjar Analytics | |
| (function (h, o, t, j, a, r) { | |
| h.hj = h.hj || function () { | |
| (h.hj.q = h.hj.q || []).push(arguments) | |
| }; | |
| h._hjSettings = {hjid: XXXX, hjsv: 6}; | |
| a = o.getElementsByTagName('head')[0]; | |
| r = o.createElement('script'); | |
| r.async = 1; | |
| r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv; | |
| a.appendChild(r); | |
| })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv='); | |
| } | |
| if (CLI.consent.analytics) | |
| { | |
| // Google Analytics | |
| (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-XXXX'); | |
| } | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment