@blotoutio/providers-google-analytics-4-sdk 1.52.1 → 1.53.1

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/index.cjs.js CHANGED
@@ -514,7 +514,8 @@ const initGA4 = (ID, advancedConsentMode, consentSkip, consentData, executionCon
514
514
  script.parentNode.insertBefore(element, script);
515
515
  }
516
516
  };
517
- const init = ({ manifest, userId, executionContext, consentData, }) => {
517
+ const init = ({ manifest, userId, executionContext, consentData, pageUrl, }) => {
518
+ var _a;
518
519
  if (!window ||
519
520
  !manifest.variables ||
520
521
  !manifest.variables['measurementId'] ||
@@ -522,19 +523,29 @@ const init = ({ manifest, userId, executionContext, consentData, }) => {
522
523
  return;
523
524
  }
524
525
  window.dataLayer = window.dataLayer || [];
525
- window.gtag = function gtag() {
526
- // eslint-disable-next-line prefer-rest-params
527
- window.dataLayer.push(arguments);
528
- };
526
+ window.gtag =
527
+ window.gtag ||
528
+ function gtag() {
529
+ // eslint-disable-next-line prefer-rest-params
530
+ window.dataLayer.push(arguments);
531
+ };
529
532
  if (!window.google_tag_manager ||
530
533
  !window.google_tag_manager[manifest.variables['measurementId']]) {
531
534
  initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], manifest.variables['consentSkip'], consentData, executionContext);
532
535
  }
533
536
  if (window.gtag) {
534
- window.gtag('config', manifest.variables['measurementId'], {
537
+ const config = {
535
538
  user_id: userId,
536
539
  send_page_view: false,
537
- });
540
+ };
541
+ // Override gtag's `dl` param so enhanced-measurement events (scroll, click,
542
+ // etc.) auto-fired by gtag use the top-frame URL instead of the iframe
543
+ // sandbox's document.location.
544
+ const resolvedPageUrl = pageUrl || ((_a = window.location) === null || _a === void 0 ? void 0 : _a.href);
545
+ if (resolvedPageUrl) {
546
+ config['page_location'] = resolvedPageUrl;
547
+ }
548
+ window.gtag('config', manifest.variables['measurementId'], config);
538
549
  }
539
550
  };
540
551
 
@@ -806,7 +817,7 @@ const tag = ({ data, eventName, manifestVariables, eventId, pageUrl, }) => {
806
817
  }
807
818
  return {
808
819
  loaded: isLoaded,
809
- sdkVersion: "1.52.1" ,
820
+ sdkVersion: "1.53.1" ,
810
821
  };
811
822
  };
812
823
 
package/index.js CHANGED
@@ -515,7 +515,8 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
515
515
  script.parentNode.insertBefore(element, script);
516
516
  }
517
517
  };
518
- const init = ({ manifest, userId, executionContext, consentData, }) => {
518
+ const init = ({ manifest, userId, executionContext, consentData, pageUrl, }) => {
519
+ var _a;
519
520
  if (!window ||
520
521
  !manifest.variables ||
521
522
  !manifest.variables['measurementId'] ||
@@ -523,19 +524,29 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
523
524
  return;
524
525
  }
525
526
  window.dataLayer = window.dataLayer || [];
526
- window.gtag = function gtag() {
527
- // eslint-disable-next-line prefer-rest-params
528
- window.dataLayer.push(arguments);
529
- };
527
+ window.gtag =
528
+ window.gtag ||
529
+ function gtag() {
530
+ // eslint-disable-next-line prefer-rest-params
531
+ window.dataLayer.push(arguments);
532
+ };
530
533
  if (!window.google_tag_manager ||
531
534
  !window.google_tag_manager[manifest.variables['measurementId']]) {
532
535
  initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], manifest.variables['consentSkip'], consentData, executionContext);
533
536
  }
534
537
  if (window.gtag) {
535
- window.gtag('config', manifest.variables['measurementId'], {
538
+ const config = {
536
539
  user_id: userId,
537
540
  send_page_view: false,
538
- });
541
+ };
542
+ // Override gtag's `dl` param so enhanced-measurement events (scroll, click,
543
+ // etc.) auto-fired by gtag use the top-frame URL instead of the iframe
544
+ // sandbox's document.location.
545
+ const resolvedPageUrl = pageUrl || ((_a = window.location) === null || _a === void 0 ? void 0 : _a.href);
546
+ if (resolvedPageUrl) {
547
+ config['page_location'] = resolvedPageUrl;
548
+ }
549
+ window.gtag('config', manifest.variables['measurementId'], config);
539
550
  }
540
551
  };
541
552
 
@@ -807,7 +818,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
807
818
  }
808
819
  return {
809
820
  loaded: isLoaded,
810
- sdkVersion: "1.52.1" ,
821
+ sdkVersion: "1.53.1" ,
811
822
  };
812
823
  };
813
824
 
package/index.mjs CHANGED
@@ -512,7 +512,8 @@ const initGA4 = (ID, advancedConsentMode, consentSkip, consentData, executionCon
512
512
  script.parentNode.insertBefore(element, script);
513
513
  }
514
514
  };
515
- const init = ({ manifest, userId, executionContext, consentData, }) => {
515
+ const init = ({ manifest, userId, executionContext, consentData, pageUrl, }) => {
516
+ var _a;
516
517
  if (!window ||
517
518
  !manifest.variables ||
518
519
  !manifest.variables['measurementId'] ||
@@ -520,19 +521,29 @@ const init = ({ manifest, userId, executionContext, consentData, }) => {
520
521
  return;
521
522
  }
522
523
  window.dataLayer = window.dataLayer || [];
523
- window.gtag = function gtag() {
524
- // eslint-disable-next-line prefer-rest-params
525
- window.dataLayer.push(arguments);
526
- };
524
+ window.gtag =
525
+ window.gtag ||
526
+ function gtag() {
527
+ // eslint-disable-next-line prefer-rest-params
528
+ window.dataLayer.push(arguments);
529
+ };
527
530
  if (!window.google_tag_manager ||
528
531
  !window.google_tag_manager[manifest.variables['measurementId']]) {
529
532
  initGA4(manifest.variables['measurementId'], manifest.variables['advancedConsentMode'], manifest.variables['consentSkip'], consentData, executionContext);
530
533
  }
531
534
  if (window.gtag) {
532
- window.gtag('config', manifest.variables['measurementId'], {
535
+ const config = {
533
536
  user_id: userId,
534
537
  send_page_view: false,
535
- });
538
+ };
539
+ // Override gtag's `dl` param so enhanced-measurement events (scroll, click,
540
+ // etc.) auto-fired by gtag use the top-frame URL instead of the iframe
541
+ // sandbox's document.location.
542
+ const resolvedPageUrl = pageUrl || ((_a = window.location) === null || _a === void 0 ? void 0 : _a.href);
543
+ if (resolvedPageUrl) {
544
+ config['page_location'] = resolvedPageUrl;
545
+ }
546
+ window.gtag('config', manifest.variables['measurementId'], config);
536
547
  }
537
548
  };
538
549
 
@@ -804,7 +815,7 @@ const tag = ({ data, eventName, manifestVariables, eventId, pageUrl, }) => {
804
815
  }
805
816
  return {
806
817
  loaded: isLoaded,
807
- sdkVersion: "1.52.1" ,
818
+ sdkVersion: "1.53.1" ,
808
819
  };
809
820
  };
810
821
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-analytics-4-sdk",
3
- "version": "1.52.1",
3
+ "version": "1.53.1",
4
4
  "description": "Google Analytics 4 Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",