@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/index.cjs
CHANGED
|
@@ -10300,7 +10300,7 @@ function BookingForm({ config, eventDetails, stripePromise, onSuccess, onError,
|
|
|
10300
10300
|
*/
|
|
10301
10301
|
/**
|
|
10302
10302
|
* Check if Google Consent Mode has granted the necessary permissions for ads tracking
|
|
10303
|
-
* This
|
|
10303
|
+
* This checks multiple sources of consent state in order of preference
|
|
10304
10304
|
*/
|
|
10305
10305
|
function checkGoogleConsent() {
|
|
10306
10306
|
console.log("[Google Ads Tracking] 🔍 Checking Google consent...");
|
|
@@ -10309,31 +10309,90 @@ function checkGoogleConsent() {
|
|
|
10309
10309
|
return false;
|
|
10310
10310
|
}
|
|
10311
10311
|
console.log("[Google Ads Tracking] ✅ Window object available");
|
|
10312
|
-
// Check for
|
|
10313
|
-
if (
|
|
10314
|
-
console.log("[Google Ads Tracking]
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10312
|
+
// Method 1: Check dataLayer for consent_update events (most reliable)
|
|
10313
|
+
if (window.dataLayer && Array.isArray(window.dataLayer)) {
|
|
10314
|
+
console.log("[Google Ads Tracking] 🔍 Checking dataLayer for consent events...");
|
|
10315
|
+
const dataLayer = window.dataLayer;
|
|
10316
|
+
// Debug: Show the entire dataLayer contents
|
|
10317
|
+
console.log("[Google Ads Tracking] 🗂️ Complete dataLayer contents:", JSON.stringify(dataLayer, null, 2));
|
|
10318
|
+
console.log("[Google Ads Tracking] 📊 dataLayer length:", dataLayer.length);
|
|
10319
|
+
// Look for the most recent consent update in dataLayer
|
|
10320
|
+
let latestConsentState = null;
|
|
10321
|
+
const foundEvents = [];
|
|
10322
|
+
// Search backwards through dataLayer for most recent consent state
|
|
10323
|
+
for (let i = dataLayer.length - 1; i >= 0; i--) {
|
|
10324
|
+
const event = dataLayer[i];
|
|
10325
|
+
console.log(`[Google Ads Tracking] 🔍 Checking dataLayer[${i}]:`, event);
|
|
10326
|
+
if (event && typeof event === "object") {
|
|
10327
|
+
// Check for various consent event patterns
|
|
10328
|
+
if (event.event === "consent_update" || event.event === "default_consent") {
|
|
10329
|
+
console.log("[Google Ads Tracking] 📋 Found consent event:", event);
|
|
10330
|
+
foundEvents.push(event);
|
|
10331
|
+
if (event.consent_mode) {
|
|
10332
|
+
latestConsentState = event.consent_mode;
|
|
10333
|
+
break;
|
|
10334
|
+
}
|
|
10335
|
+
}
|
|
10336
|
+
// Also check for direct consent_mode properties
|
|
10337
|
+
if (event.consent_mode) {
|
|
10338
|
+
console.log("[Google Ads Tracking] 📋 Found consent_mode property:", event);
|
|
10339
|
+
foundEvents.push(event);
|
|
10340
|
+
latestConsentState = event.consent_mode;
|
|
10341
|
+
break;
|
|
10342
|
+
}
|
|
10343
|
+
}
|
|
10326
10344
|
}
|
|
10327
|
-
|
|
10328
|
-
|
|
10345
|
+
console.log("[Google Ads Tracking] 📋 All found consent events:", foundEvents);
|
|
10346
|
+
if (latestConsentState) {
|
|
10347
|
+
const adStorageGranted = latestConsentState.ad_storage === "granted";
|
|
10348
|
+
console.log("[Google Ads Tracking] 🔐 ad_storage from dataLayer:", latestConsentState.ad_storage);
|
|
10349
|
+
console.log("[Google Ads Tracking] 🎯 Consent result from dataLayer:", adStorageGranted);
|
|
10350
|
+
return adStorageGranted;
|
|
10351
|
+
}
|
|
10352
|
+
console.log("[Google Ads Tracking] ❌ No consent events found in dataLayer");
|
|
10353
|
+
}
|
|
10354
|
+
console.log("[Google Ads Tracking] ❌ dataLayer not found or not an array");
|
|
10355
|
+
// Method 2: Check for cookie-based consent (fallback for host implementation)
|
|
10356
|
+
console.log("[Google Ads Tracking] 🔍 Checking cookie-based consent...");
|
|
10357
|
+
try {
|
|
10358
|
+
// Debug: Show all cookies
|
|
10359
|
+
console.log("[Google Ads Tracking] 🍪 All cookies:", document.cookie);
|
|
10360
|
+
const allCookies = document.cookie.split(";").map((cookie) => cookie.trim());
|
|
10361
|
+
console.log("[Google Ads Tracking] 🍪 Parsed cookies:", allCookies);
|
|
10362
|
+
// Check for the host page's conversion tracking consent cookie
|
|
10363
|
+
const conversionTrackingCookie = document.cookie
|
|
10364
|
+
.split(";")
|
|
10365
|
+
.find((cookie) => cookie.trim().startsWith("conversionTrackingConsent="));
|
|
10366
|
+
if (conversionTrackingCookie) {
|
|
10367
|
+
const cookieValue = conversionTrackingCookie.split("=")[1];
|
|
10368
|
+
const isGranted = cookieValue === "true";
|
|
10369
|
+
console.log("[Google Ads Tracking] 🍪 Found conversionTrackingConsent cookie:", cookieValue);
|
|
10370
|
+
console.log("[Google Ads Tracking] 🎯 Consent result from cookie:", isGranted);
|
|
10371
|
+
return isGranted;
|
|
10372
|
+
}
|
|
10373
|
+
console.log("[Google Ads Tracking] ❌ conversionTrackingConsent cookie not found");
|
|
10374
|
+
// Also check for other potential cookie names
|
|
10375
|
+
const alternativeCookieNames = ["analyticsConsent", "ads_consent", "ad_storage"];
|
|
10376
|
+
for (const cookieName of alternativeCookieNames) {
|
|
10377
|
+
const alternativeCookie = allCookies.find((cookie) => cookie.startsWith(`${cookieName}=`));
|
|
10378
|
+
if (alternativeCookie) {
|
|
10379
|
+
console.log(`[Google Ads Tracking] 🍪 Found alternative cookie ${cookieName}:`, alternativeCookie);
|
|
10380
|
+
}
|
|
10329
10381
|
}
|
|
10330
10382
|
}
|
|
10383
|
+
catch (error) {
|
|
10384
|
+
console.warn("[Google Ads Tracking] ⚠️ Error checking cookies:", error);
|
|
10385
|
+
}
|
|
10386
|
+
// Method 3: Check if gtag exists but no consent state found
|
|
10387
|
+
if (typeof window.gtag === "function") {
|
|
10388
|
+
console.log("[Google Ads Tracking] ⚠️ gtag function exists but no consent state found");
|
|
10389
|
+
console.log("[Google Ads Tracking] 💡 This might indicate consent hasn't been set yet");
|
|
10390
|
+
}
|
|
10331
10391
|
else {
|
|
10332
10392
|
console.log("[Google Ads Tracking] ❌ gtag function not found");
|
|
10333
10393
|
}
|
|
10334
|
-
// If
|
|
10335
|
-
|
|
10336
|
-
console.log("[Google Ads Tracking] 🚫 No consent mechanism found, returning false");
|
|
10394
|
+
// If no consent mechanism is found, assume consent is not granted
|
|
10395
|
+
console.log("[Google Ads Tracking] 🚫 No valid consent state found, returning false");
|
|
10337
10396
|
return false;
|
|
10338
10397
|
}
|
|
10339
10398
|
/**
|