@bigz-app/booking-widget 0.3.3 → 0.3.5
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/README.md +2 -1
- package/dist/booking-widget.js +3 -28
- package/dist/booking-widget.js.map +1 -1
- package/dist/components/shared/DialogPortal.d.ts.map +1 -1
- package/dist/index.cjs +3 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +3 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/google-ads-tracking.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,7 +113,8 @@ const config = {
|
|
|
113
113
|
tagId: 'AW-XXXXXXX', // Your Google Ads Tag ID (required)
|
|
114
114
|
conversionId: 'booking_conversion', // Your conversion label (required)
|
|
115
115
|
conversionCurrency: 'EUR', // Optional, defaults to 'EUR'
|
|
116
|
-
includeValue: true // Optional, defaults to true
|
|
116
|
+
includeValue: true, // Optional, defaults to true
|
|
117
|
+
consent: true // send the users consent to the widget when initializing.
|
|
117
118
|
}
|
|
118
119
|
};
|
|
119
120
|
```
|
package/dist/booking-widget.js
CHANGED
|
@@ -6839,7 +6839,6 @@
|
|
|
6839
6839
|
}
|
|
6840
6840
|
catch (error) {
|
|
6841
6841
|
// Ignore removal errors - element may have already been removed
|
|
6842
|
-
console.debug("Portal cleanup: Element already removed");
|
|
6843
6842
|
}
|
|
6844
6843
|
}
|
|
6845
6844
|
document.body.style.overflow = "";
|
|
@@ -10367,27 +10366,23 @@
|
|
|
10367
10366
|
*/
|
|
10368
10367
|
function isGtagAvailable() {
|
|
10369
10368
|
if (typeof window === "undefined") {
|
|
10370
|
-
console.warn("[Google Ads] window is undefined (SSR context)");
|
|
10371
10369
|
return false;
|
|
10372
10370
|
}
|
|
10373
10371
|
// Check current window
|
|
10374
10372
|
if (typeof window.gtag === "function") {
|
|
10375
|
-
console.log("[Google Ads] gtag found in current window");
|
|
10376
10373
|
return true;
|
|
10377
10374
|
}
|
|
10378
10375
|
// Check parent window (for iframe/widget scenarios)
|
|
10379
10376
|
if (window !== window.parent) {
|
|
10380
10377
|
try {
|
|
10381
10378
|
if (typeof window.parent?.gtag === "function") {
|
|
10382
|
-
console.log("[Google Ads] gtag found in parent window");
|
|
10383
10379
|
return true;
|
|
10384
10380
|
}
|
|
10385
10381
|
}
|
|
10386
10382
|
catch (e) {
|
|
10387
|
-
|
|
10383
|
+
// Cannot access parent window (cross-origin)
|
|
10388
10384
|
}
|
|
10389
10385
|
}
|
|
10390
|
-
console.log("[Google Ads] gtag not found");
|
|
10391
10386
|
return false;
|
|
10392
10387
|
}
|
|
10393
10388
|
/**
|
|
@@ -10395,31 +10390,25 @@
|
|
|
10395
10390
|
*/
|
|
10396
10391
|
function initializeGtag(tagId) {
|
|
10397
10392
|
if (typeof window === "undefined") {
|
|
10398
|
-
console.warn("[Google Ads] window is undefined, cannot initialize gtag");
|
|
10399
10393
|
return;
|
|
10400
10394
|
}
|
|
10401
10395
|
// Skip if gtag already exists
|
|
10402
10396
|
if (isGtagAvailable()) {
|
|
10403
|
-
console.log("[Google Ads] gtag already initialized, skipping init");
|
|
10404
10397
|
return;
|
|
10405
10398
|
}
|
|
10406
10399
|
// Initialize dataLayer and gtag function
|
|
10407
|
-
console.log("[Google Ads] Initializing dataLayer and gtag function");
|
|
10408
10400
|
window.dataLayer = window.dataLayer || [];
|
|
10409
10401
|
window.gtag = (...args) => {
|
|
10410
10402
|
window.dataLayer.push(args);
|
|
10411
10403
|
};
|
|
10412
10404
|
// Set current timestamp
|
|
10413
|
-
console.log("[Google Ads] Setting gtag timestamp");
|
|
10414
10405
|
window.gtag("js", new Date());
|
|
10415
10406
|
// Load gtag script
|
|
10416
|
-
console.log("[Google Ads] Loading gtag script from:", `https://www.googletagmanager.com/gtag/js?id=${tagId}`);
|
|
10417
10407
|
const script = document.createElement("script");
|
|
10418
10408
|
script.async = true;
|
|
10419
10409
|
script.src = `https://www.googletagmanager.com/gtag/js?id=${tagId}`;
|
|
10420
10410
|
document.head.appendChild(script);
|
|
10421
10411
|
// Configure the tag
|
|
10422
|
-
console.log("[Google Ads] Configuring gtag with tagId:", tagId);
|
|
10423
10412
|
window.gtag("config", tagId, {
|
|
10424
10413
|
anonymize_ip: true,
|
|
10425
10414
|
allow_google_signals: false,
|
|
@@ -10431,7 +10420,6 @@
|
|
|
10431
10420
|
*/
|
|
10432
10421
|
function sendConversion(config) {
|
|
10433
10422
|
if (typeof window === "undefined") {
|
|
10434
|
-
console.warn("[Google Ads] window is undefined, cannot send conversion");
|
|
10435
10423
|
return;
|
|
10436
10424
|
}
|
|
10437
10425
|
let gtag = window.gtag;
|
|
@@ -10439,16 +10427,12 @@
|
|
|
10439
10427
|
if (typeof gtag !== "function" && window !== window.parent) {
|
|
10440
10428
|
try {
|
|
10441
10429
|
gtag = window.parent?.gtag;
|
|
10442
|
-
if (typeof gtag === "function") {
|
|
10443
|
-
console.log("[Google Ads] Using parent window gtag");
|
|
10444
|
-
}
|
|
10445
10430
|
}
|
|
10446
10431
|
catch {
|
|
10447
|
-
|
|
10432
|
+
// Cannot access parent window (cross-origin)
|
|
10448
10433
|
}
|
|
10449
10434
|
}
|
|
10450
10435
|
if (typeof gtag !== "function") {
|
|
10451
|
-
console.warn("[Google Ads] gtag not available, cannot send conversion");
|
|
10452
10436
|
return;
|
|
10453
10437
|
}
|
|
10454
10438
|
// Build conversion data
|
|
@@ -10465,7 +10449,6 @@
|
|
|
10465
10449
|
if (config.transactionId) {
|
|
10466
10450
|
conversionData.transaction_id = config.transactionId;
|
|
10467
10451
|
}
|
|
10468
|
-
console.log("[Google Ads] Dispatching conversion event:", conversionData);
|
|
10469
10452
|
// Send conversion event
|
|
10470
10453
|
gtag("event", "conversion", conversionData);
|
|
10471
10454
|
}
|
|
@@ -10476,22 +10459,14 @@
|
|
|
10476
10459
|
function handleGoogleAdsConversion(config) {
|
|
10477
10460
|
// Validate required config
|
|
10478
10461
|
if (!config.tagId || !config.conversionId) {
|
|
10479
|
-
console.warn("[Google Ads] Missing tagId or conversionId", config);
|
|
10480
10462
|
return;
|
|
10481
10463
|
}
|
|
10482
|
-
console.log("[Google Ads] Waiting 1500ms before tracking conversion...");
|
|
10483
10464
|
// Wait 1500ms before proceeding
|
|
10484
10465
|
setTimeout(() => {
|
|
10485
|
-
console.log("[Google Ads] Checking if gtag is available...");
|
|
10486
10466
|
// Check if gtag is available, initialize if not
|
|
10487
10467
|
if (!isGtagAvailable()) {
|
|
10488
|
-
console.log("[Google Ads] gtag not found, initializing...");
|
|
10489
10468
|
initializeGtag(config.tagId);
|
|
10490
10469
|
}
|
|
10491
|
-
else {
|
|
10492
|
-
console.log("[Google Ads] gtag already available.");
|
|
10493
|
-
}
|
|
10494
|
-
console.log("[Google Ads] Sending conversion event...", config);
|
|
10495
10470
|
sendConversion(config);
|
|
10496
10471
|
}, 1500);
|
|
10497
10472
|
}
|
|
@@ -10547,7 +10522,7 @@
|
|
|
10547
10522
|
config.googleAds?.conversionId &&
|
|
10548
10523
|
config.googleAds?.consent !== false) {
|
|
10549
10524
|
// Prepare conversion tracking data
|
|
10550
|
-
const conversionValue = data.order.total;
|
|
10525
|
+
const conversionValue = data.order.total / 100;
|
|
10551
10526
|
const transactionId = data.order.id;
|
|
10552
10527
|
// Track the conversion
|
|
10553
10528
|
handleGoogleAdsConversion({
|