PageSourceSearch

https://hackathon-planning-kit.org/js/analytics.js

js hackathon-planning-kit.org collected 2026-10-03 23:13:21 UTC 1,887 bytes, 48 lines download raw bytes

1/*
2 * Script to enable Google Analytics for this website.
3 */
4const GA_MEASUREMENT_ID = "G-4TNGT8TGMK";
5const EU_COUNTRIES = ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE"];
6
7// Set up dataLayer and gtag immediately — the script tag in <head> is already loading
8window.dataLayer = window.dataLayer || [];
9function gtag() { dataLayer.push(arguments); }
10gtag("js", new Date());
11gtag("config", GA_MEASUREMENT_ID);
12
13$(document).ready(function () {
14
15    $.get("https://ipapi.co/json/", function (data) {
16        let userCountry = data.country_code;
17        let consent = localStorage.getItem("ga_consent");
18
19        if (EU_COUNTRIES.includes(userCountry)) {
20            if (consent === "granted") {
21                // Already consented — nothing to do, GA is already running
22            } else if (consent === null) {
23                // First visit — show banner
24                $("#cookiebanner").addClass("show");
25            }
26            // consent === "denied": GA should not run — disable it
27            if (consent !== "granted") {
28                gtag("consent", "update", { analytics_storage: "denied" });
29            }
30        }
31        // Non-EU: GA runs without consent, no banner
32
33        // Accept
34        $("#acceptcookies").off("click").on("click", function () {
35            localStorage.setItem("ga_consent", "granted");
36            $("#cookiebanner").removeClass("show");
37            gtag("consent", "update", { analytics_storage: "granted" });
38        });
39
40        // Decline
41        $("#rejectcookies").off("click").on("click", function () {
42            localStorage.setItem("ga_consent", "denied");
43            $("#cookiebanner").removeClass("show");
44            gtag("consent", "update", { analytics_storage: "denied" });
45        });
46    });
47
48});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.