PageSourceSearch

https://irdproducts.com/consent-test.js

js irdproducts.com collected 2026-10-02 14:15:31 UTC 1,639 bytes, 49 lines download raw bytes

1// Google Consent Mode Test Utility
2// Use this in browser console to verify consent mode is working
3
4window.testConsentMode = function () {
5  console.log("🧪 Testing Google Consent Mode Configuration...\n");
6
7  // Check if gtag is available
8  if (typeof window.gtag === "undefined") {
9    console.error(
10      "❌ gtag is not available. Make sure Google Tag Manager is loaded."
11    );
12    return;
13  }
14
15  // Check localStorage for consent status
16  const savedConsent = localStorage.getItem("cookieConsent");
17  console.log("💾 Saved consent in localStorage:", savedConsent);
18
19  // Check if dataLayer exists and has consent events
20  if (window.dataLayer) {
21    const consentEvents = window.dataLayer.filter(
22      (event) => event && (event[0] === "consent" || event.event === "consent")
23    );
24    console.log("📊 Consent events in dataLayer:", consentEvents);
25  }
26
27  // Test consent update
28  console.log("\n🔄 Testing consent update...");
29  window.gtag("consent", "update", {
30    analytics_storage: "granted",
31  });
32  console.log("✅ Analytics consent granted via update");
33
34  // Check current dataLayer state
35  console.log("\n📈 Current dataLayer:", window.dataLayer.slice(-5));
36
37  console.log("\n✅ Consent Mode test completed!");
38  console.log("Expected behavior:");
39  console.log(
40    '- In-Page Default: All non-essential consent should be "denied"'
41  );
42  console.log(
43    '- In-Page Update: Consent should update to "granted" when user accepts'
44  );
45};
46
47// Auto-run basic check
48console.log("🚀 Google Consent Mode Test Utility loaded");
49console.log("Run window.testConsentMode() in console to verify configuration");

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.