|
|
Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */ | | /* Any JavaScript here will be loaded for all users on every page load. */ |
| // Cookie Consent + Google Analytics 4 (GDPR-kompatibel)
| |
| window.addEventListener("load", function () {
| |
| window.cookieconsent.initialise({
| |
| palette: {
| |
| popup: { background: "#000" },
| |
| button: { background: "#f1d600" }
| |
| },
| |
| theme: "classic",
| |
| type: "opt-in", // kräver samtycke innan spårning
| |
| content: {
| |
| message: "Vi använder cookies för att förbättra din upplevelse.",
| |
| dismiss: "Acceptera",
| |
| deny: "Nej tack",
| |
| link: "Läs mer",
| |
| href: "/index.php/Privacy_policy" // ändra till din sida om integritet
| |
| },
| |
| onInitialise: function (status) {
| |
| if (status == "allow") loadAnalytics();
| |
| },
| |
| onStatusChange: function (status) {
| |
| if (status == "allow") loadAnalytics();
| |
| }
| |
| });
| |
|
| |
| function loadAnalytics() {
| |
| window.dataLayer = window.dataLayer || [];
| |
| function gtag() { dataLayer.push(arguments); }
| |
| gtag('js', new Date());
| |
| gtag('config', 'G-69RWRYHQ2C'); // din GA4-ID
| |
|
| |
| var gaScript = document.createElement('script');
| |
| gaScript.async = true;
| |
| gaScript.src = 'https://www.googletagmanager.com/gtag/js?id=G-69RWRYHQ2C';
| |
| document.head.appendChild(gaScript);
| |
| }
| |
|
| |
| var ccScript = document.createElement('script');
| |
| ccScript.src = "https://cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.1/cookieconsent.min.js";
| |
| ccScript.defer = true;
| |
| document.head.appendChild(ccScript);
| |
| });
| |