@blotoutio/providers-google-ads-clicks-sdk 1.63.2 → 1.64.0

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.
Files changed (4) hide show
  1. package/index.cjs.js +103 -11
  2. package/index.js +103 -11
  3. package/index.mjs +103 -11
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -450,7 +450,31 @@ const usStates = new Map([
450
450
  ['US-UM', 'United States Minor Outlying Islands'],
451
451
  ['US-VI', 'Virgin Islands, U.S.'],
452
452
  ]);
453
- new Set([...isoCountries.keys(), ...usStates.keys()]);
453
+ /**
454
+ * ISO 3166-2:CA province and territory codes, keyed `CA-XX` to mirror
455
+ * `usStates`. Used by the consent banner's Canada region to offer province
456
+ * selection (Québec is treated specially by the regional consent config).
457
+ */
458
+ const caProvinces = new Map([
459
+ ['CA-AB', 'Alberta'],
460
+ ['CA-BC', 'British Columbia'],
461
+ ['CA-MB', 'Manitoba'],
462
+ ['CA-NB', 'New Brunswick'],
463
+ ['CA-NL', 'Newfoundland and Labrador'],
464
+ ['CA-NS', 'Nova Scotia'],
465
+ ['CA-NT', 'Northwest Territories'],
466
+ ['CA-NU', 'Nunavut'],
467
+ ['CA-ON', 'Ontario'],
468
+ ['CA-PE', 'Prince Edward Island'],
469
+ ['CA-QC', 'Quebec'],
470
+ ['CA-SK', 'Saskatchewan'],
471
+ ['CA-YT', 'Yukon'],
472
+ ]);
473
+ new Set([
474
+ ...isoCountries.keys(),
475
+ ...usStates.keys(),
476
+ ...caProvinces.keys(),
477
+ ]);
454
478
 
455
479
  /**
456
480
  * Exact utm_source normalization (lowercase key → canonical name).
@@ -805,7 +829,7 @@ const sendDynamicRemarketingEvent = (eventName, manifestVariables, data, pageUrl
805
829
  };
806
830
 
807
831
  // eslint-disable-next-line @nx/enforce-module-boundaries
808
- const initGAds = (ID, consentData, executionContext, consentSkip) => {
832
+ const initGAds = (ID, consentData, executionContext, consentSkip, sdkUrl) => {
809
833
  var _a;
810
834
  if (!window.gtag) {
811
835
  return;
@@ -837,14 +861,16 @@ const initGAds = (ID, consentData, executionContext, consentSkip) => {
837
861
  window.gtag('js', new Date());
838
862
  const element = document.createElement('script');
839
863
  element.async = !0;
840
- element.src = `https://www.googletagmanager.com/gtag/js?id=${ID}`;
864
+ // Use the custom destination URL (e.g. Google Tag Gateway) verbatim if
865
+ // provided, otherwise fall back to the standard googletagmanager.com URL.
866
+ element.src = sdkUrl || `https://www.googletagmanager.com/gtag/js?id=${ID}`;
841
867
  const script = document.getElementsByTagName('script')[0];
842
868
  if (script && script.parentNode) {
843
869
  script.parentNode.insertBefore(element, script);
844
870
  }
845
871
  };
846
872
  const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
847
- var _a, _b, _c, _d, _e, _f;
873
+ var _a, _b, _c, _d, _e, _f, _g;
848
874
  const shouldLoadSDK = ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['loadSDK']) === '1' ||
849
875
  ((_b = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _b === void 0 ? void 0 : _b['dynamicRemarketingEnabled']) === '1';
850
876
  if (typeof window === 'undefined' ||
@@ -871,13 +897,15 @@ const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
871
897
  };
872
898
  if (!window.google_tag_manager ||
873
899
  !window.google_tag_manager[manifest.variables['tagId']]) {
874
- initGAds(manifest.variables['tagId'], consentData, executionContext, (_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['consentSkip']);
900
+ initGAds(manifest.variables['tagId'], consentData, executionContext, (_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['consentSkip'], (_g = manifest.variables) === null || _g === void 0 ? void 0 : _g['sdkUrl']);
875
901
  }
876
902
  if (window.gtag) {
877
903
  window.gtag('config', manifest.variables['tagId'], customConfig);
878
904
  }
879
905
  };
880
906
 
907
+ const keyPrefix = `_worker`;
908
+
881
909
  const getCookieValue = (key) => {
882
910
  var _a;
883
911
  try {
@@ -914,16 +942,67 @@ const parseCookies = (cookie) => {
914
942
  }));
915
943
  };
916
944
 
945
+ const initKey = `${keyPrefix}StoreMultiple`;
946
+ const getData = (destination, persistType, key = initKey) => {
947
+ let data;
948
+ if (persistType === 'session') {
949
+ data = getSession(key);
950
+ }
951
+ else {
952
+ data = getLocal(key);
953
+ }
954
+ return (data === null || data === void 0 ? void 0 : data[destination]) || {};
955
+ };
956
+ const getLocal = (key) => {
957
+ try {
958
+ if (!localStorage) {
959
+ return {};
960
+ }
961
+ const data = localStorage.getItem(key);
962
+ if (!data) {
963
+ return {};
964
+ }
965
+ return JSON.parse(data) || {};
966
+ }
967
+ catch {
968
+ return {};
969
+ }
970
+ };
971
+ const getSession = (key) => {
972
+ try {
973
+ if (!sessionStorage) {
974
+ return {};
975
+ }
976
+ const data = sessionStorage.getItem(key);
977
+ if (!data) {
978
+ return {};
979
+ }
980
+ return JSON.parse(data) || {};
981
+ }
982
+ catch {
983
+ return {};
984
+ }
985
+ };
986
+
917
987
  const getIsNewCustomerFlag = async (getData) => {
918
988
  const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
919
989
  return isNewCustomer ? isNewCustomer === 'true' : undefined;
920
990
  };
991
+ // Reads the isNewCustomer flag already persisted in the browser's session KV
992
+ // (written by the `data` API call, which runs before the Purchase event). Lets
993
+ // callers use the local value and avoid a redundant edge round-trip; returns
994
+ // undefined when the value has not been stored yet so the caller can fall back.
995
+ const getIsNewCustomerFromBrowser = (destination) => {
996
+ const kv = getData(destination, 'session')['kv'];
997
+ const isNewCustomer = kv === null || kv === void 0 ? void 0 : kv['isNewCustomer'];
998
+ return isNewCustomer ? isNewCustomer === 'true' : undefined;
999
+ };
921
1000
 
922
1001
  const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdgeData, }) => {
923
1002
  var _a;
924
1003
  const result = {
925
1004
  isFired: false,
926
- sdkVersion: "1.63.2" ,
1005
+ sdkVersion: "1.64.0" ,
927
1006
  };
928
1007
  if (!eventName || !window.gtag || !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'])) {
929
1008
  return result;
@@ -961,11 +1040,24 @@ const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdge
961
1040
  (_a = window.gtag) === null || _a === void 0 ? void 0 : _a.call(window, 'event', 'conversion', conversionPayload);
962
1041
  };
963
1042
  if (eventName === 'Purchase' &&
964
- (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1' &&
965
- getEdgeData) {
966
- getIsNewCustomerFlag(getEdgeData)
967
- .then(fireConversion)
968
- .catch(() => fireConversion());
1043
+ (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1') {
1044
+ // Prefer the isNewCustomer flag already saved in the browser (e.g. by the
1045
+ // Shopify pixel's `data` call, which runs before Purchase). Only query the
1046
+ // edge when the browser value is missing.
1047
+ const browserValue = destination
1048
+ ? getIsNewCustomerFromBrowser(destination)
1049
+ : undefined;
1050
+ if (typeof browserValue === 'boolean') {
1051
+ fireConversion(browserValue);
1052
+ }
1053
+ else if (getEdgeData) {
1054
+ getIsNewCustomerFlag(getEdgeData)
1055
+ .then(fireConversion)
1056
+ .catch(() => fireConversion());
1057
+ }
1058
+ else {
1059
+ fireConversion();
1060
+ }
969
1061
  }
970
1062
  else {
971
1063
  fireConversion();
package/index.js CHANGED
@@ -451,7 +451,31 @@ var ProvidersGoogleAdsClicksSdk = (function () {
451
451
  ['US-UM', 'United States Minor Outlying Islands'],
452
452
  ['US-VI', 'Virgin Islands, U.S.'],
453
453
  ]);
454
- new Set([...isoCountries.keys(), ...usStates.keys()]);
454
+ /**
455
+ * ISO 3166-2:CA province and territory codes, keyed `CA-XX` to mirror
456
+ * `usStates`. Used by the consent banner's Canada region to offer province
457
+ * selection (Québec is treated specially by the regional consent config).
458
+ */
459
+ const caProvinces = new Map([
460
+ ['CA-AB', 'Alberta'],
461
+ ['CA-BC', 'British Columbia'],
462
+ ['CA-MB', 'Manitoba'],
463
+ ['CA-NB', 'New Brunswick'],
464
+ ['CA-NL', 'Newfoundland and Labrador'],
465
+ ['CA-NS', 'Nova Scotia'],
466
+ ['CA-NT', 'Northwest Territories'],
467
+ ['CA-NU', 'Nunavut'],
468
+ ['CA-ON', 'Ontario'],
469
+ ['CA-PE', 'Prince Edward Island'],
470
+ ['CA-QC', 'Quebec'],
471
+ ['CA-SK', 'Saskatchewan'],
472
+ ['CA-YT', 'Yukon'],
473
+ ]);
474
+ new Set([
475
+ ...isoCountries.keys(),
476
+ ...usStates.keys(),
477
+ ...caProvinces.keys(),
478
+ ]);
455
479
 
456
480
  /**
457
481
  * Exact utm_source normalization (lowercase key → canonical name).
@@ -806,7 +830,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
806
830
  };
807
831
 
808
832
  // eslint-disable-next-line @nx/enforce-module-boundaries
809
- const initGAds = (ID, consentData, executionContext, consentSkip) => {
833
+ const initGAds = (ID, consentData, executionContext, consentSkip, sdkUrl) => {
810
834
  var _a;
811
835
  if (!window.gtag) {
812
836
  return;
@@ -838,14 +862,16 @@ var ProvidersGoogleAdsClicksSdk = (function () {
838
862
  window.gtag('js', new Date());
839
863
  const element = document.createElement('script');
840
864
  element.async = !0;
841
- element.src = `https://www.googletagmanager.com/gtag/js?id=${ID}`;
865
+ // Use the custom destination URL (e.g. Google Tag Gateway) verbatim if
866
+ // provided, otherwise fall back to the standard googletagmanager.com URL.
867
+ element.src = sdkUrl || `https://www.googletagmanager.com/gtag/js?id=${ID}`;
842
868
  const script = document.getElementsByTagName('script')[0];
843
869
  if (script && script.parentNode) {
844
870
  script.parentNode.insertBefore(element, script);
845
871
  }
846
872
  };
847
873
  const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
848
- var _a, _b, _c, _d, _e, _f;
874
+ var _a, _b, _c, _d, _e, _f, _g;
849
875
  const shouldLoadSDK = ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['loadSDK']) === '1' ||
850
876
  ((_b = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _b === void 0 ? void 0 : _b['dynamicRemarketingEnabled']) === '1';
851
877
  if (typeof window === 'undefined' ||
@@ -872,13 +898,15 @@ var ProvidersGoogleAdsClicksSdk = (function () {
872
898
  };
873
899
  if (!window.google_tag_manager ||
874
900
  !window.google_tag_manager[manifest.variables['tagId']]) {
875
- initGAds(manifest.variables['tagId'], consentData, executionContext, (_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['consentSkip']);
901
+ initGAds(manifest.variables['tagId'], consentData, executionContext, (_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['consentSkip'], (_g = manifest.variables) === null || _g === void 0 ? void 0 : _g['sdkUrl']);
876
902
  }
877
903
  if (window.gtag) {
878
904
  window.gtag('config', manifest.variables['tagId'], customConfig);
879
905
  }
880
906
  };
881
907
 
908
+ const keyPrefix = `_worker`;
909
+
882
910
  const getCookieValue = (key) => {
883
911
  var _a;
884
912
  try {
@@ -915,16 +943,67 @@ var ProvidersGoogleAdsClicksSdk = (function () {
915
943
  }));
916
944
  };
917
945
 
946
+ const initKey = `${keyPrefix}StoreMultiple`;
947
+ const getData = (destination, persistType, key = initKey) => {
948
+ let data;
949
+ if (persistType === 'session') {
950
+ data = getSession(key);
951
+ }
952
+ else {
953
+ data = getLocal(key);
954
+ }
955
+ return (data === null || data === void 0 ? void 0 : data[destination]) || {};
956
+ };
957
+ const getLocal = (key) => {
958
+ try {
959
+ if (!localStorage) {
960
+ return {};
961
+ }
962
+ const data = localStorage.getItem(key);
963
+ if (!data) {
964
+ return {};
965
+ }
966
+ return JSON.parse(data) || {};
967
+ }
968
+ catch {
969
+ return {};
970
+ }
971
+ };
972
+ const getSession = (key) => {
973
+ try {
974
+ if (!sessionStorage) {
975
+ return {};
976
+ }
977
+ const data = sessionStorage.getItem(key);
978
+ if (!data) {
979
+ return {};
980
+ }
981
+ return JSON.parse(data) || {};
982
+ }
983
+ catch {
984
+ return {};
985
+ }
986
+ };
987
+
918
988
  const getIsNewCustomerFlag = async (getData) => {
919
989
  const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
920
990
  return isNewCustomer ? isNewCustomer === 'true' : undefined;
921
991
  };
992
+ // Reads the isNewCustomer flag already persisted in the browser's session KV
993
+ // (written by the `data` API call, which runs before the Purchase event). Lets
994
+ // callers use the local value and avoid a redundant edge round-trip; returns
995
+ // undefined when the value has not been stored yet so the caller can fall back.
996
+ const getIsNewCustomerFromBrowser = (destination) => {
997
+ const kv = getData(destination, 'session')['kv'];
998
+ const isNewCustomer = kv === null || kv === void 0 ? void 0 : kv['isNewCustomer'];
999
+ return isNewCustomer ? isNewCustomer === 'true' : undefined;
1000
+ };
922
1001
 
923
1002
  const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdgeData, }) => {
924
1003
  var _a;
925
1004
  const result = {
926
1005
  isFired: false,
927
- sdkVersion: "1.63.2" ,
1006
+ sdkVersion: "1.64.0" ,
928
1007
  };
929
1008
  if (!eventName || !window.gtag || !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'])) {
930
1009
  return result;
@@ -962,11 +1041,24 @@ var ProvidersGoogleAdsClicksSdk = (function () {
962
1041
  (_a = window.gtag) === null || _a === void 0 ? void 0 : _a.call(window, 'event', 'conversion', conversionPayload);
963
1042
  };
964
1043
  if (eventName === 'Purchase' &&
965
- (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1' &&
966
- getEdgeData) {
967
- getIsNewCustomerFlag(getEdgeData)
968
- .then(fireConversion)
969
- .catch(() => fireConversion());
1044
+ (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1') {
1045
+ // Prefer the isNewCustomer flag already saved in the browser (e.g. by the
1046
+ // Shopify pixel's `data` call, which runs before Purchase). Only query the
1047
+ // edge when the browser value is missing.
1048
+ const browserValue = destination
1049
+ ? getIsNewCustomerFromBrowser(destination)
1050
+ : undefined;
1051
+ if (typeof browserValue === 'boolean') {
1052
+ fireConversion(browserValue);
1053
+ }
1054
+ else if (getEdgeData) {
1055
+ getIsNewCustomerFlag(getEdgeData)
1056
+ .then(fireConversion)
1057
+ .catch(() => fireConversion());
1058
+ }
1059
+ else {
1060
+ fireConversion();
1061
+ }
970
1062
  }
971
1063
  else {
972
1064
  fireConversion();
package/index.mjs CHANGED
@@ -448,7 +448,31 @@ const usStates = new Map([
448
448
  ['US-UM', 'United States Minor Outlying Islands'],
449
449
  ['US-VI', 'Virgin Islands, U.S.'],
450
450
  ]);
451
- new Set([...isoCountries.keys(), ...usStates.keys()]);
451
+ /**
452
+ * ISO 3166-2:CA province and territory codes, keyed `CA-XX` to mirror
453
+ * `usStates`. Used by the consent banner's Canada region to offer province
454
+ * selection (Québec is treated specially by the regional consent config).
455
+ */
456
+ const caProvinces = new Map([
457
+ ['CA-AB', 'Alberta'],
458
+ ['CA-BC', 'British Columbia'],
459
+ ['CA-MB', 'Manitoba'],
460
+ ['CA-NB', 'New Brunswick'],
461
+ ['CA-NL', 'Newfoundland and Labrador'],
462
+ ['CA-NS', 'Nova Scotia'],
463
+ ['CA-NT', 'Northwest Territories'],
464
+ ['CA-NU', 'Nunavut'],
465
+ ['CA-ON', 'Ontario'],
466
+ ['CA-PE', 'Prince Edward Island'],
467
+ ['CA-QC', 'Quebec'],
468
+ ['CA-SK', 'Saskatchewan'],
469
+ ['CA-YT', 'Yukon'],
470
+ ]);
471
+ new Set([
472
+ ...isoCountries.keys(),
473
+ ...usStates.keys(),
474
+ ...caProvinces.keys(),
475
+ ]);
452
476
 
453
477
  /**
454
478
  * Exact utm_source normalization (lowercase key → canonical name).
@@ -803,7 +827,7 @@ const sendDynamicRemarketingEvent = (eventName, manifestVariables, data, pageUrl
803
827
  };
804
828
 
805
829
  // eslint-disable-next-line @nx/enforce-module-boundaries
806
- const initGAds = (ID, consentData, executionContext, consentSkip) => {
830
+ const initGAds = (ID, consentData, executionContext, consentSkip, sdkUrl) => {
807
831
  var _a;
808
832
  if (!window.gtag) {
809
833
  return;
@@ -835,14 +859,16 @@ const initGAds = (ID, consentData, executionContext, consentSkip) => {
835
859
  window.gtag('js', new Date());
836
860
  const element = document.createElement('script');
837
861
  element.async = !0;
838
- element.src = `https://www.googletagmanager.com/gtag/js?id=${ID}`;
862
+ // Use the custom destination URL (e.g. Google Tag Gateway) verbatim if
863
+ // provided, otherwise fall back to the standard googletagmanager.com URL.
864
+ element.src = sdkUrl || `https://www.googletagmanager.com/gtag/js?id=${ID}`;
839
865
  const script = document.getElementsByTagName('script')[0];
840
866
  if (script && script.parentNode) {
841
867
  script.parentNode.insertBefore(element, script);
842
868
  }
843
869
  };
844
870
  const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
845
- var _a, _b, _c, _d, _e, _f;
871
+ var _a, _b, _c, _d, _e, _f, _g;
846
872
  const shouldLoadSDK = ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['loadSDK']) === '1' ||
847
873
  ((_b = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _b === void 0 ? void 0 : _b['dynamicRemarketingEnabled']) === '1';
848
874
  if (typeof window === 'undefined' ||
@@ -869,13 +895,15 @@ const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
869
895
  };
870
896
  if (!window.google_tag_manager ||
871
897
  !window.google_tag_manager[manifest.variables['tagId']]) {
872
- initGAds(manifest.variables['tagId'], consentData, executionContext, (_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['consentSkip']);
898
+ initGAds(manifest.variables['tagId'], consentData, executionContext, (_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['consentSkip'], (_g = manifest.variables) === null || _g === void 0 ? void 0 : _g['sdkUrl']);
873
899
  }
874
900
  if (window.gtag) {
875
901
  window.gtag('config', manifest.variables['tagId'], customConfig);
876
902
  }
877
903
  };
878
904
 
905
+ const keyPrefix = `_worker`;
906
+
879
907
  const getCookieValue = (key) => {
880
908
  var _a;
881
909
  try {
@@ -912,16 +940,67 @@ const parseCookies = (cookie) => {
912
940
  }));
913
941
  };
914
942
 
943
+ const initKey = `${keyPrefix}StoreMultiple`;
944
+ const getData = (destination, persistType, key = initKey) => {
945
+ let data;
946
+ if (persistType === 'session') {
947
+ data = getSession(key);
948
+ }
949
+ else {
950
+ data = getLocal(key);
951
+ }
952
+ return (data === null || data === void 0 ? void 0 : data[destination]) || {};
953
+ };
954
+ const getLocal = (key) => {
955
+ try {
956
+ if (!localStorage) {
957
+ return {};
958
+ }
959
+ const data = localStorage.getItem(key);
960
+ if (!data) {
961
+ return {};
962
+ }
963
+ return JSON.parse(data) || {};
964
+ }
965
+ catch {
966
+ return {};
967
+ }
968
+ };
969
+ const getSession = (key) => {
970
+ try {
971
+ if (!sessionStorage) {
972
+ return {};
973
+ }
974
+ const data = sessionStorage.getItem(key);
975
+ if (!data) {
976
+ return {};
977
+ }
978
+ return JSON.parse(data) || {};
979
+ }
980
+ catch {
981
+ return {};
982
+ }
983
+ };
984
+
915
985
  const getIsNewCustomerFlag = async (getData) => {
916
986
  const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
917
987
  return isNewCustomer ? isNewCustomer === 'true' : undefined;
918
988
  };
989
+ // Reads the isNewCustomer flag already persisted in the browser's session KV
990
+ // (written by the `data` API call, which runs before the Purchase event). Lets
991
+ // callers use the local value and avoid a redundant edge round-trip; returns
992
+ // undefined when the value has not been stored yet so the caller can fall back.
993
+ const getIsNewCustomerFromBrowser = (destination) => {
994
+ const kv = getData(destination, 'session')['kv'];
995
+ const isNewCustomer = kv === null || kv === void 0 ? void 0 : kv['isNewCustomer'];
996
+ return isNewCustomer ? isNewCustomer === 'true' : undefined;
997
+ };
919
998
 
920
999
  const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdgeData, }) => {
921
1000
  var _a;
922
1001
  const result = {
923
1002
  isFired: false,
924
- sdkVersion: "1.63.2" ,
1003
+ sdkVersion: "1.64.0" ,
925
1004
  };
926
1005
  if (!eventName || !window.gtag || !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'])) {
927
1006
  return result;
@@ -959,11 +1038,24 @@ const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdge
959
1038
  (_a = window.gtag) === null || _a === void 0 ? void 0 : _a.call(window, 'event', 'conversion', conversionPayload);
960
1039
  };
961
1040
  if (eventName === 'Purchase' &&
962
- (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1' &&
963
- getEdgeData) {
964
- getIsNewCustomerFlag(getEdgeData)
965
- .then(fireConversion)
966
- .catch(() => fireConversion());
1041
+ (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1') {
1042
+ // Prefer the isNewCustomer flag already saved in the browser (e.g. by the
1043
+ // Shopify pixel's `data` call, which runs before Purchase). Only query the
1044
+ // edge when the browser value is missing.
1045
+ const browserValue = destination
1046
+ ? getIsNewCustomerFromBrowser(destination)
1047
+ : undefined;
1048
+ if (typeof browserValue === 'boolean') {
1049
+ fireConversion(browserValue);
1050
+ }
1051
+ else if (getEdgeData) {
1052
+ getIsNewCustomerFlag(getEdgeData)
1053
+ .then(fireConversion)
1054
+ .catch(() => fireConversion());
1055
+ }
1056
+ else {
1057
+ fireConversion();
1058
+ }
967
1059
  }
968
1060
  else {
969
1061
  fireConversion();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-ads-clicks-sdk",
3
- "version": "1.63.2",
3
+ "version": "1.64.0",
4
4
  "description": "Google Ads Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",