@bigz-app/booking-widget 0.3.3 → 0.3.4
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 +2 -27
- package/dist/booking-widget.js.map +1 -1
- package/dist/components/shared/DialogPortal.d.ts.map +1 -1
- package/dist/index.cjs +2 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +2 -27
- 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/dist/index.esm.js
CHANGED
|
@@ -6781,7 +6781,6 @@ function DialogPortal({ children, isOpen, zIndex = 999999, }) {
|
|
|
6781
6781
|
}
|
|
6782
6782
|
catch (error) {
|
|
6783
6783
|
// Ignore removal errors - element may have already been removed
|
|
6784
|
-
console.debug("Portal cleanup: Element already removed");
|
|
6785
6784
|
}
|
|
6786
6785
|
}
|
|
6787
6786
|
document.body.style.overflow = "";
|
|
@@ -10282,27 +10281,23 @@ function BookingForm({ config, eventDetails, stripePromise, onSuccess, onError,
|
|
|
10282
10281
|
*/
|
|
10283
10282
|
function isGtagAvailable() {
|
|
10284
10283
|
if (typeof window === "undefined") {
|
|
10285
|
-
console.warn("[Google Ads] window is undefined (SSR context)");
|
|
10286
10284
|
return false;
|
|
10287
10285
|
}
|
|
10288
10286
|
// Check current window
|
|
10289
10287
|
if (typeof window.gtag === "function") {
|
|
10290
|
-
console.log("[Google Ads] gtag found in current window");
|
|
10291
10288
|
return true;
|
|
10292
10289
|
}
|
|
10293
10290
|
// Check parent window (for iframe/widget scenarios)
|
|
10294
10291
|
if (window !== window.parent) {
|
|
10295
10292
|
try {
|
|
10296
10293
|
if (typeof window.parent?.gtag === "function") {
|
|
10297
|
-
console.log("[Google Ads] gtag found in parent window");
|
|
10298
10294
|
return true;
|
|
10299
10295
|
}
|
|
10300
10296
|
}
|
|
10301
10297
|
catch (e) {
|
|
10302
|
-
|
|
10298
|
+
// Cannot access parent window (cross-origin)
|
|
10303
10299
|
}
|
|
10304
10300
|
}
|
|
10305
|
-
console.log("[Google Ads] gtag not found");
|
|
10306
10301
|
return false;
|
|
10307
10302
|
}
|
|
10308
10303
|
/**
|
|
@@ -10310,31 +10305,25 @@ function isGtagAvailable() {
|
|
|
10310
10305
|
*/
|
|
10311
10306
|
function initializeGtag(tagId) {
|
|
10312
10307
|
if (typeof window === "undefined") {
|
|
10313
|
-
console.warn("[Google Ads] window is undefined, cannot initialize gtag");
|
|
10314
10308
|
return;
|
|
10315
10309
|
}
|
|
10316
10310
|
// Skip if gtag already exists
|
|
10317
10311
|
if (isGtagAvailable()) {
|
|
10318
|
-
console.log("[Google Ads] gtag already initialized, skipping init");
|
|
10319
10312
|
return;
|
|
10320
10313
|
}
|
|
10321
10314
|
// Initialize dataLayer and gtag function
|
|
10322
|
-
console.log("[Google Ads] Initializing dataLayer and gtag function");
|
|
10323
10315
|
window.dataLayer = window.dataLayer || [];
|
|
10324
10316
|
window.gtag = (...args) => {
|
|
10325
10317
|
window.dataLayer.push(args);
|
|
10326
10318
|
};
|
|
10327
10319
|
// Set current timestamp
|
|
10328
|
-
console.log("[Google Ads] Setting gtag timestamp");
|
|
10329
10320
|
window.gtag("js", new Date());
|
|
10330
10321
|
// Load gtag script
|
|
10331
|
-
console.log("[Google Ads] Loading gtag script from:", `https://www.googletagmanager.com/gtag/js?id=${tagId}`);
|
|
10332
10322
|
const script = document.createElement("script");
|
|
10333
10323
|
script.async = true;
|
|
10334
10324
|
script.src = `https://www.googletagmanager.com/gtag/js?id=${tagId}`;
|
|
10335
10325
|
document.head.appendChild(script);
|
|
10336
10326
|
// Configure the tag
|
|
10337
|
-
console.log("[Google Ads] Configuring gtag with tagId:", tagId);
|
|
10338
10327
|
window.gtag("config", tagId, {
|
|
10339
10328
|
anonymize_ip: true,
|
|
10340
10329
|
allow_google_signals: false,
|
|
@@ -10346,7 +10335,6 @@ function initializeGtag(tagId) {
|
|
|
10346
10335
|
*/
|
|
10347
10336
|
function sendConversion(config) {
|
|
10348
10337
|
if (typeof window === "undefined") {
|
|
10349
|
-
console.warn("[Google Ads] window is undefined, cannot send conversion");
|
|
10350
10338
|
return;
|
|
10351
10339
|
}
|
|
10352
10340
|
let gtag = window.gtag;
|
|
@@ -10354,16 +10342,12 @@ function sendConversion(config) {
|
|
|
10354
10342
|
if (typeof gtag !== "function" && window !== window.parent) {
|
|
10355
10343
|
try {
|
|
10356
10344
|
gtag = window.parent?.gtag;
|
|
10357
|
-
if (typeof gtag === "function") {
|
|
10358
|
-
console.log("[Google Ads] Using parent window gtag");
|
|
10359
|
-
}
|
|
10360
10345
|
}
|
|
10361
10346
|
catch {
|
|
10362
|
-
|
|
10347
|
+
// Cannot access parent window (cross-origin)
|
|
10363
10348
|
}
|
|
10364
10349
|
}
|
|
10365
10350
|
if (typeof gtag !== "function") {
|
|
10366
|
-
console.warn("[Google Ads] gtag not available, cannot send conversion");
|
|
10367
10351
|
return;
|
|
10368
10352
|
}
|
|
10369
10353
|
// Build conversion data
|
|
@@ -10380,7 +10364,6 @@ function sendConversion(config) {
|
|
|
10380
10364
|
if (config.transactionId) {
|
|
10381
10365
|
conversionData.transaction_id = config.transactionId;
|
|
10382
10366
|
}
|
|
10383
|
-
console.log("[Google Ads] Dispatching conversion event:", conversionData);
|
|
10384
10367
|
// Send conversion event
|
|
10385
10368
|
gtag("event", "conversion", conversionData);
|
|
10386
10369
|
}
|
|
@@ -10391,22 +10374,14 @@ function sendConversion(config) {
|
|
|
10391
10374
|
function handleGoogleAdsConversion(config) {
|
|
10392
10375
|
// Validate required config
|
|
10393
10376
|
if (!config.tagId || !config.conversionId) {
|
|
10394
|
-
console.warn("[Google Ads] Missing tagId or conversionId", config);
|
|
10395
10377
|
return;
|
|
10396
10378
|
}
|
|
10397
|
-
console.log("[Google Ads] Waiting 1500ms before tracking conversion...");
|
|
10398
10379
|
// Wait 1500ms before proceeding
|
|
10399
10380
|
setTimeout(() => {
|
|
10400
|
-
console.log("[Google Ads] Checking if gtag is available...");
|
|
10401
10381
|
// Check if gtag is available, initialize if not
|
|
10402
10382
|
if (!isGtagAvailable()) {
|
|
10403
|
-
console.log("[Google Ads] gtag not found, initializing...");
|
|
10404
10383
|
initializeGtag(config.tagId);
|
|
10405
10384
|
}
|
|
10406
|
-
else {
|
|
10407
|
-
console.log("[Google Ads] gtag already available.");
|
|
10408
|
-
}
|
|
10409
|
-
console.log("[Google Ads] Sending conversion event...", config);
|
|
10410
10385
|
sendConversion(config);
|
|
10411
10386
|
}, 1500);
|
|
10412
10387
|
}
|