@bigz-app/booking-widget 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/booking-widget.js +79 -20
- package/dist/booking-widget.js.map +1 -1
- package/dist/index.cjs +79 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +79 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/google-ads-tracking.d.ts +1 -1
- package/dist/utils/google-ads-tracking.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/booking-widget.js
CHANGED
|
@@ -10365,7 +10365,7 @@
|
|
|
10365
10365
|
*/
|
|
10366
10366
|
/**
|
|
10367
10367
|
* Check if Google Consent Mode has granted the necessary permissions for ads tracking
|
|
10368
|
-
* This
|
|
10368
|
+
* This checks multiple sources of consent state in order of preference
|
|
10369
10369
|
*/
|
|
10370
10370
|
function checkGoogleConsent() {
|
|
10371
10371
|
console.log("[Google Ads Tracking] 🔍 Checking Google consent...");
|
|
@@ -10374,31 +10374,90 @@
|
|
|
10374
10374
|
return false;
|
|
10375
10375
|
}
|
|
10376
10376
|
console.log("[Google Ads Tracking] ✅ Window object available");
|
|
10377
|
-
// Check for
|
|
10378
|
-
if (
|
|
10379
|
-
console.log("[Google Ads Tracking]
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10377
|
+
// Method 1: Check dataLayer for consent_update events (most reliable)
|
|
10378
|
+
if (window.dataLayer && Array.isArray(window.dataLayer)) {
|
|
10379
|
+
console.log("[Google Ads Tracking] 🔍 Checking dataLayer for consent events...");
|
|
10380
|
+
const dataLayer = window.dataLayer;
|
|
10381
|
+
// Debug: Show the entire dataLayer contents
|
|
10382
|
+
console.log("[Google Ads Tracking] 🗂️ Complete dataLayer contents:", JSON.stringify(dataLayer, null, 2));
|
|
10383
|
+
console.log("[Google Ads Tracking] 📊 dataLayer length:", dataLayer.length);
|
|
10384
|
+
// Look for the most recent consent update in dataLayer
|
|
10385
|
+
let latestConsentState = null;
|
|
10386
|
+
const foundEvents = [];
|
|
10387
|
+
// Search backwards through dataLayer for most recent consent state
|
|
10388
|
+
for (let i = dataLayer.length - 1; i >= 0; i--) {
|
|
10389
|
+
const event = dataLayer[i];
|
|
10390
|
+
console.log(`[Google Ads Tracking] 🔍 Checking dataLayer[${i}]:`, event);
|
|
10391
|
+
if (event && typeof event === "object") {
|
|
10392
|
+
// Check for various consent event patterns
|
|
10393
|
+
if (event.event === "consent_update" || event.event === "default_consent") {
|
|
10394
|
+
console.log("[Google Ads Tracking] 📋 Found consent event:", event);
|
|
10395
|
+
foundEvents.push(event);
|
|
10396
|
+
if (event.consent_mode) {
|
|
10397
|
+
latestConsentState = event.consent_mode;
|
|
10398
|
+
break;
|
|
10399
|
+
}
|
|
10400
|
+
}
|
|
10401
|
+
// Also check for direct consent_mode properties
|
|
10402
|
+
if (event.consent_mode) {
|
|
10403
|
+
console.log("[Google Ads Tracking] 📋 Found consent_mode property:", event);
|
|
10404
|
+
foundEvents.push(event);
|
|
10405
|
+
latestConsentState = event.consent_mode;
|
|
10406
|
+
break;
|
|
10407
|
+
}
|
|
10408
|
+
}
|
|
10391
10409
|
}
|
|
10392
|
-
|
|
10393
|
-
|
|
10410
|
+
console.log("[Google Ads Tracking] 📋 All found consent events:", foundEvents);
|
|
10411
|
+
if (latestConsentState) {
|
|
10412
|
+
const adStorageGranted = latestConsentState.ad_storage === "granted";
|
|
10413
|
+
console.log("[Google Ads Tracking] 🔐 ad_storage from dataLayer:", latestConsentState.ad_storage);
|
|
10414
|
+
console.log("[Google Ads Tracking] 🎯 Consent result from dataLayer:", adStorageGranted);
|
|
10415
|
+
return adStorageGranted;
|
|
10416
|
+
}
|
|
10417
|
+
console.log("[Google Ads Tracking] ❌ No consent events found in dataLayer");
|
|
10418
|
+
}
|
|
10419
|
+
console.log("[Google Ads Tracking] ❌ dataLayer not found or not an array");
|
|
10420
|
+
// Method 2: Check for cookie-based consent (fallback for host implementation)
|
|
10421
|
+
console.log("[Google Ads Tracking] 🔍 Checking cookie-based consent...");
|
|
10422
|
+
try {
|
|
10423
|
+
// Debug: Show all cookies
|
|
10424
|
+
console.log("[Google Ads Tracking] 🍪 All cookies:", document.cookie);
|
|
10425
|
+
const allCookies = document.cookie.split(";").map((cookie) => cookie.trim());
|
|
10426
|
+
console.log("[Google Ads Tracking] 🍪 Parsed cookies:", allCookies);
|
|
10427
|
+
// Check for the host page's conversion tracking consent cookie
|
|
10428
|
+
const conversionTrackingCookie = document.cookie
|
|
10429
|
+
.split(";")
|
|
10430
|
+
.find((cookie) => cookie.trim().startsWith("conversionTrackingConsent="));
|
|
10431
|
+
if (conversionTrackingCookie) {
|
|
10432
|
+
const cookieValue = conversionTrackingCookie.split("=")[1];
|
|
10433
|
+
const isGranted = cookieValue === "true";
|
|
10434
|
+
console.log("[Google Ads Tracking] 🍪 Found conversionTrackingConsent cookie:", cookieValue);
|
|
10435
|
+
console.log("[Google Ads Tracking] 🎯 Consent result from cookie:", isGranted);
|
|
10436
|
+
return isGranted;
|
|
10437
|
+
}
|
|
10438
|
+
console.log("[Google Ads Tracking] ❌ conversionTrackingConsent cookie not found");
|
|
10439
|
+
// Also check for other potential cookie names
|
|
10440
|
+
const alternativeCookieNames = ["analyticsConsent", "ads_consent", "ad_storage"];
|
|
10441
|
+
for (const cookieName of alternativeCookieNames) {
|
|
10442
|
+
const alternativeCookie = allCookies.find((cookie) => cookie.startsWith(`${cookieName}=`));
|
|
10443
|
+
if (alternativeCookie) {
|
|
10444
|
+
console.log(`[Google Ads Tracking] 🍪 Found alternative cookie ${cookieName}:`, alternativeCookie);
|
|
10445
|
+
}
|
|
10394
10446
|
}
|
|
10395
10447
|
}
|
|
10448
|
+
catch (error) {
|
|
10449
|
+
console.warn("[Google Ads Tracking] ⚠️ Error checking cookies:", error);
|
|
10450
|
+
}
|
|
10451
|
+
// Method 3: Check if gtag exists but no consent state found
|
|
10452
|
+
if (typeof window.gtag === "function") {
|
|
10453
|
+
console.log("[Google Ads Tracking] ⚠️ gtag function exists but no consent state found");
|
|
10454
|
+
console.log("[Google Ads Tracking] 💡 This might indicate consent hasn't been set yet");
|
|
10455
|
+
}
|
|
10396
10456
|
else {
|
|
10397
10457
|
console.log("[Google Ads Tracking] ❌ gtag function not found");
|
|
10398
10458
|
}
|
|
10399
|
-
// If
|
|
10400
|
-
|
|
10401
|
-
console.log("[Google Ads Tracking] 🚫 No consent mechanism found, returning false");
|
|
10459
|
+
// If no consent mechanism is found, assume consent is not granted
|
|
10460
|
+
console.log("[Google Ads Tracking] 🚫 No valid consent state found, returning false");
|
|
10402
10461
|
return false;
|
|
10403
10462
|
}
|
|
10404
10463
|
/**
|