@blotoutio/providers-google-ads-clicks-sdk 1.68.1 → 1.69.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.
- package/index.cjs.js +57 -10
- package/index.js +57 -10
- package/index.mjs +57 -10
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -596,6 +596,18 @@ new Set([
|
|
|
596
596
|
]);
|
|
597
597
|
|
|
598
598
|
const packageName = 'googleAdsClicks';
|
|
599
|
+
/**
|
|
600
|
+
* The browser and server must send the exact same transactionId for Google to
|
|
601
|
+
* deduplicate the pair, so both the SDK and the edge derive it here — order id
|
|
602
|
+
* when there is one, else the shared event id — and can never disagree.
|
|
603
|
+
*
|
|
604
|
+
* It is sent as-is, NOT truncated. v1 has always sent the raw order id, and a
|
|
605
|
+
* real order/event id sits well within Google's 64-char limit. Slicing to 64
|
|
606
|
+
* would both silently change v1's long ids and collapse two distinct ids that
|
|
607
|
+
* share a 64-char prefix onto the same dedup key (undercounting). A pathological
|
|
608
|
+
* over-64 id is better rejected visibly by Google than mangled into a collision.
|
|
609
|
+
*/
|
|
610
|
+
const buildTransactionId = (orderId, eventId) => (orderId === null || orderId === void 0 ? void 0 : orderId.toString()) || (eventId === null || eventId === void 0 ? void 0 : eventId.toString()) || '';
|
|
599
611
|
|
|
600
612
|
const getGoogleConsent = (consentData) => {
|
|
601
613
|
const gadsConsent = hasUserConsentForProvider(consentData, 'googleAdsClicks');
|
|
@@ -610,7 +622,7 @@ const getIdentifierValue = (identifier, contentItem) => {
|
|
|
610
622
|
if (!contentItem) {
|
|
611
623
|
return identifierValue;
|
|
612
624
|
}
|
|
613
|
-
identifierValue = identifierValue.replaceAll('{productId}', contentItem.id);
|
|
625
|
+
identifierValue = identifierValue.replaceAll('{productId}', contentItem.id || '');
|
|
614
626
|
identifierValue = identifierValue.replaceAll('{variantId}', contentItem.variantId || '');
|
|
615
627
|
identifierValue = identifierValue.replaceAll('{sku}', contentItem.sku || '');
|
|
616
628
|
return identifierValue;
|
|
@@ -624,7 +636,19 @@ const getConversionLabel = (eventName, manifestVariables) => {
|
|
|
624
636
|
const mapping = mappings.find((mappingItem) => mappingItem.eventName === eventName);
|
|
625
637
|
return mapping === null || mapping === void 0 ? void 0 : mapping.browserConversionLabel;
|
|
626
638
|
};
|
|
627
|
-
|
|
639
|
+
/**
|
|
640
|
+
* Builds the gtag conversion payload.
|
|
641
|
+
*
|
|
642
|
+
* `eventId` matters on v2 only. There, the server sends the same conversion to
|
|
643
|
+
* the same conversion action, and Google deduplicates the pair on
|
|
644
|
+
* `transaction_id` — so every conversion needs one. Purchases have an order id;
|
|
645
|
+
* Lead, SignUp and AddToCart don't, and without a fallback those would count
|
|
646
|
+
* twice. `eventId` is the same value the edge sees on `payload.eventId`, so both
|
|
647
|
+
* sides agree. On v1 there is no eventId fallback — it keeps the raw order id
|
|
648
|
+
* exactly as before the migration, since v1 has no server counterpart to dedupe
|
|
649
|
+
* against.
|
|
650
|
+
*/
|
|
651
|
+
const getEventData = (data, isNewCustomer, eventId) => {
|
|
628
652
|
const eventData = {};
|
|
629
653
|
if (!data) {
|
|
630
654
|
return eventData;
|
|
@@ -635,7 +659,19 @@ const getEventData = (data, isNewCustomer) => {
|
|
|
635
659
|
if (data['currency']) {
|
|
636
660
|
eventData.currency = data['currency'];
|
|
637
661
|
}
|
|
638
|
-
|
|
662
|
+
// `eventId` is passed only on v2 (see tag.ts: `isDataManager ? eventId :
|
|
663
|
+
// undefined`), so its presence marks the v2 path.
|
|
664
|
+
if (eventId !== undefined) {
|
|
665
|
+
// v2: same derivation as the edge (buildTransactionId), sent as-is, so the
|
|
666
|
+
// browser and server dedup keys are always byte-identical.
|
|
667
|
+
const transactionId = buildTransactionId(data['orderId'], eventId);
|
|
668
|
+
if (transactionId) {
|
|
669
|
+
eventData.transaction_id = transactionId;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
else if (data['orderId']) {
|
|
673
|
+
// v1 unchanged: the raw order id exactly as before the migration — no
|
|
674
|
+
// stringify, no eventId fallback — so the dark launch stays v1-identical.
|
|
639
675
|
eventData.transaction_id = data['orderId'];
|
|
640
676
|
}
|
|
641
677
|
if (typeof isNewCustomer === 'boolean') {
|
|
@@ -872,7 +908,7 @@ const initGAds = (ID, consentData, executionContext, consentSkip, sdkUrl) => {
|
|
|
872
908
|
}
|
|
873
909
|
};
|
|
874
910
|
const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
|
|
875
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
911
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
876
912
|
const shouldLoadSDK = ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['loadSDK']) === '1' ||
|
|
877
913
|
((_b = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _b === void 0 ? void 0 : _b['dynamicRemarketingEnabled']) === '1';
|
|
878
914
|
if (typeof window === 'undefined' ||
|
|
@@ -887,7 +923,9 @@ const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
|
|
|
887
923
|
if (resolvedPageUrl) {
|
|
888
924
|
customConfig['page_location'] = resolvedPageUrl;
|
|
889
925
|
}
|
|
890
|
-
|
|
926
|
+
// v2 always drives enhanced conversions through gtag, so it needs this too.
|
|
927
|
+
if (((_e = manifest.variables) === null || _e === void 0 ? void 0 : _e['apiVersion']) === '2' ||
|
|
928
|
+
((_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['enhancedConversionsSetting']) === 'gtag') {
|
|
891
929
|
customConfig['allow_enhanced_conversions'] = true;
|
|
892
930
|
}
|
|
893
931
|
window.dataLayer = window.dataLayer || [];
|
|
@@ -899,7 +937,7 @@ const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
|
|
|
899
937
|
};
|
|
900
938
|
if (!window.google_tag_manager ||
|
|
901
939
|
!window.google_tag_manager[manifest.variables['tagId']]) {
|
|
902
|
-
initGAds(manifest.variables['tagId'], consentData, executionContext, (
|
|
940
|
+
initGAds(manifest.variables['tagId'], consentData, executionContext, (_g = manifest.variables) === null || _g === void 0 ? void 0 : _g['consentSkip'], (_h = manifest.variables) === null || _h === void 0 ? void 0 : _h['sdkUrl']);
|
|
903
941
|
}
|
|
904
942
|
if (window.gtag) {
|
|
905
943
|
window.gtag('config', manifest.variables['tagId'], customConfig);
|
|
@@ -964,11 +1002,11 @@ const getIsNewCustomerFromBrowser = (destination) => {
|
|
|
964
1002
|
return isNewCustomer ? isNewCustomer === 'true' : undefined;
|
|
965
1003
|
};
|
|
966
1004
|
|
|
967
|
-
const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdgeData, }) => {
|
|
1005
|
+
const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl, getEdgeData, }) => {
|
|
968
1006
|
var _a, _b;
|
|
969
1007
|
const result = {
|
|
970
1008
|
isFired: false,
|
|
971
|
-
sdkVersion: "1.
|
|
1009
|
+
sdkVersion: "1.69.0" ,
|
|
972
1010
|
};
|
|
973
1011
|
const tagId = manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'];
|
|
974
1012
|
if (!eventName || !window.gtag || !tagId) {
|
|
@@ -986,14 +1024,23 @@ const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdge
|
|
|
986
1024
|
if ((manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1') {
|
|
987
1025
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
988
1026
|
if (conversionLabel) {
|
|
989
|
-
|
|
1027
|
+
const isDataManager = manifestVariables['apiVersion'] === '2';
|
|
1028
|
+
/*
|
|
1029
|
+
* On v2 the browser is the primary source of user data: Google now accepts
|
|
1030
|
+
* user-provided data from the tag, Data Manager and the API at once, so
|
|
1031
|
+
* there is no adjustment upload to attach it server-side. Consent is
|
|
1032
|
+
* handled by Consent Mode — `init` sets ad_user_data/ad_personalization
|
|
1033
|
+
* from the user's consent, and gtag withholds user data when they're denied.
|
|
1034
|
+
*/
|
|
1035
|
+
if ((isDataManager ||
|
|
1036
|
+
manifestVariables['enhancedConversionsSetting'] === 'gtag') &&
|
|
990
1037
|
destination) {
|
|
991
1038
|
window.gtag('set', 'user_data', getUserData(destination));
|
|
992
1039
|
}
|
|
993
1040
|
const cartData = getCartData(manifestVariables, data);
|
|
994
1041
|
const fireConversion = (isNewCustomer) => {
|
|
995
1042
|
var _a;
|
|
996
|
-
const eventData = getEventData(data, isNewCustomer);
|
|
1043
|
+
const eventData = getEventData(data, isNewCustomer, isDataManager ? eventId : undefined);
|
|
997
1044
|
const conversionPayload = {
|
|
998
1045
|
send_to: conversionLabel,
|
|
999
1046
|
...eventData,
|
package/index.js
CHANGED
|
@@ -597,6 +597,18 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
597
597
|
]);
|
|
598
598
|
|
|
599
599
|
const packageName = 'googleAdsClicks';
|
|
600
|
+
/**
|
|
601
|
+
* The browser and server must send the exact same transactionId for Google to
|
|
602
|
+
* deduplicate the pair, so both the SDK and the edge derive it here — order id
|
|
603
|
+
* when there is one, else the shared event id — and can never disagree.
|
|
604
|
+
*
|
|
605
|
+
* It is sent as-is, NOT truncated. v1 has always sent the raw order id, and a
|
|
606
|
+
* real order/event id sits well within Google's 64-char limit. Slicing to 64
|
|
607
|
+
* would both silently change v1's long ids and collapse two distinct ids that
|
|
608
|
+
* share a 64-char prefix onto the same dedup key (undercounting). A pathological
|
|
609
|
+
* over-64 id is better rejected visibly by Google than mangled into a collision.
|
|
610
|
+
*/
|
|
611
|
+
const buildTransactionId = (orderId, eventId) => (orderId === null || orderId === void 0 ? void 0 : orderId.toString()) || (eventId === null || eventId === void 0 ? void 0 : eventId.toString()) || '';
|
|
600
612
|
|
|
601
613
|
const getGoogleConsent = (consentData) => {
|
|
602
614
|
const gadsConsent = hasUserConsentForProvider(consentData, 'googleAdsClicks');
|
|
@@ -611,7 +623,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
611
623
|
if (!contentItem) {
|
|
612
624
|
return identifierValue;
|
|
613
625
|
}
|
|
614
|
-
identifierValue = identifierValue.replaceAll('{productId}', contentItem.id);
|
|
626
|
+
identifierValue = identifierValue.replaceAll('{productId}', contentItem.id || '');
|
|
615
627
|
identifierValue = identifierValue.replaceAll('{variantId}', contentItem.variantId || '');
|
|
616
628
|
identifierValue = identifierValue.replaceAll('{sku}', contentItem.sku || '');
|
|
617
629
|
return identifierValue;
|
|
@@ -625,7 +637,19 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
625
637
|
const mapping = mappings.find((mappingItem) => mappingItem.eventName === eventName);
|
|
626
638
|
return mapping === null || mapping === void 0 ? void 0 : mapping.browserConversionLabel;
|
|
627
639
|
};
|
|
628
|
-
|
|
640
|
+
/**
|
|
641
|
+
* Builds the gtag conversion payload.
|
|
642
|
+
*
|
|
643
|
+
* `eventId` matters on v2 only. There, the server sends the same conversion to
|
|
644
|
+
* the same conversion action, and Google deduplicates the pair on
|
|
645
|
+
* `transaction_id` — so every conversion needs one. Purchases have an order id;
|
|
646
|
+
* Lead, SignUp and AddToCart don't, and without a fallback those would count
|
|
647
|
+
* twice. `eventId` is the same value the edge sees on `payload.eventId`, so both
|
|
648
|
+
* sides agree. On v1 there is no eventId fallback — it keeps the raw order id
|
|
649
|
+
* exactly as before the migration, since v1 has no server counterpart to dedupe
|
|
650
|
+
* against.
|
|
651
|
+
*/
|
|
652
|
+
const getEventData = (data, isNewCustomer, eventId) => {
|
|
629
653
|
const eventData = {};
|
|
630
654
|
if (!data) {
|
|
631
655
|
return eventData;
|
|
@@ -636,7 +660,19 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
636
660
|
if (data['currency']) {
|
|
637
661
|
eventData.currency = data['currency'];
|
|
638
662
|
}
|
|
639
|
-
|
|
663
|
+
// `eventId` is passed only on v2 (see tag.ts: `isDataManager ? eventId :
|
|
664
|
+
// undefined`), so its presence marks the v2 path.
|
|
665
|
+
if (eventId !== undefined) {
|
|
666
|
+
// v2: same derivation as the edge (buildTransactionId), sent as-is, so the
|
|
667
|
+
// browser and server dedup keys are always byte-identical.
|
|
668
|
+
const transactionId = buildTransactionId(data['orderId'], eventId);
|
|
669
|
+
if (transactionId) {
|
|
670
|
+
eventData.transaction_id = transactionId;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
else if (data['orderId']) {
|
|
674
|
+
// v1 unchanged: the raw order id exactly as before the migration — no
|
|
675
|
+
// stringify, no eventId fallback — so the dark launch stays v1-identical.
|
|
640
676
|
eventData.transaction_id = data['orderId'];
|
|
641
677
|
}
|
|
642
678
|
if (typeof isNewCustomer === 'boolean') {
|
|
@@ -873,7 +909,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
873
909
|
}
|
|
874
910
|
};
|
|
875
911
|
const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
|
|
876
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
912
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
877
913
|
const shouldLoadSDK = ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['loadSDK']) === '1' ||
|
|
878
914
|
((_b = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _b === void 0 ? void 0 : _b['dynamicRemarketingEnabled']) === '1';
|
|
879
915
|
if (typeof window === 'undefined' ||
|
|
@@ -888,7 +924,9 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
888
924
|
if (resolvedPageUrl) {
|
|
889
925
|
customConfig['page_location'] = resolvedPageUrl;
|
|
890
926
|
}
|
|
891
|
-
|
|
927
|
+
// v2 always drives enhanced conversions through gtag, so it needs this too.
|
|
928
|
+
if (((_e = manifest.variables) === null || _e === void 0 ? void 0 : _e['apiVersion']) === '2' ||
|
|
929
|
+
((_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['enhancedConversionsSetting']) === 'gtag') {
|
|
892
930
|
customConfig['allow_enhanced_conversions'] = true;
|
|
893
931
|
}
|
|
894
932
|
window.dataLayer = window.dataLayer || [];
|
|
@@ -900,7 +938,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
900
938
|
};
|
|
901
939
|
if (!window.google_tag_manager ||
|
|
902
940
|
!window.google_tag_manager[manifest.variables['tagId']]) {
|
|
903
|
-
initGAds(manifest.variables['tagId'], consentData, executionContext, (
|
|
941
|
+
initGAds(manifest.variables['tagId'], consentData, executionContext, (_g = manifest.variables) === null || _g === void 0 ? void 0 : _g['consentSkip'], (_h = manifest.variables) === null || _h === void 0 ? void 0 : _h['sdkUrl']);
|
|
904
942
|
}
|
|
905
943
|
if (window.gtag) {
|
|
906
944
|
window.gtag('config', manifest.variables['tagId'], customConfig);
|
|
@@ -965,11 +1003,11 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
965
1003
|
return isNewCustomer ? isNewCustomer === 'true' : undefined;
|
|
966
1004
|
};
|
|
967
1005
|
|
|
968
|
-
const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdgeData, }) => {
|
|
1006
|
+
const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl, getEdgeData, }) => {
|
|
969
1007
|
var _a, _b;
|
|
970
1008
|
const result = {
|
|
971
1009
|
isFired: false,
|
|
972
|
-
sdkVersion: "1.
|
|
1010
|
+
sdkVersion: "1.69.0" ,
|
|
973
1011
|
};
|
|
974
1012
|
const tagId = manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'];
|
|
975
1013
|
if (!eventName || !window.gtag || !tagId) {
|
|
@@ -987,14 +1025,23 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
987
1025
|
if ((manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1') {
|
|
988
1026
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
989
1027
|
if (conversionLabel) {
|
|
990
|
-
|
|
1028
|
+
const isDataManager = manifestVariables['apiVersion'] === '2';
|
|
1029
|
+
/*
|
|
1030
|
+
* On v2 the browser is the primary source of user data: Google now accepts
|
|
1031
|
+
* user-provided data from the tag, Data Manager and the API at once, so
|
|
1032
|
+
* there is no adjustment upload to attach it server-side. Consent is
|
|
1033
|
+
* handled by Consent Mode — `init` sets ad_user_data/ad_personalization
|
|
1034
|
+
* from the user's consent, and gtag withholds user data when they're denied.
|
|
1035
|
+
*/
|
|
1036
|
+
if ((isDataManager ||
|
|
1037
|
+
manifestVariables['enhancedConversionsSetting'] === 'gtag') &&
|
|
991
1038
|
destination) {
|
|
992
1039
|
window.gtag('set', 'user_data', getUserData(destination));
|
|
993
1040
|
}
|
|
994
1041
|
const cartData = getCartData(manifestVariables, data);
|
|
995
1042
|
const fireConversion = (isNewCustomer) => {
|
|
996
1043
|
var _a;
|
|
997
|
-
const eventData = getEventData(data, isNewCustomer);
|
|
1044
|
+
const eventData = getEventData(data, isNewCustomer, isDataManager ? eventId : undefined);
|
|
998
1045
|
const conversionPayload = {
|
|
999
1046
|
send_to: conversionLabel,
|
|
1000
1047
|
...eventData,
|
package/index.mjs
CHANGED
|
@@ -594,6 +594,18 @@ new Set([
|
|
|
594
594
|
]);
|
|
595
595
|
|
|
596
596
|
const packageName = 'googleAdsClicks';
|
|
597
|
+
/**
|
|
598
|
+
* The browser and server must send the exact same transactionId for Google to
|
|
599
|
+
* deduplicate the pair, so both the SDK and the edge derive it here — order id
|
|
600
|
+
* when there is one, else the shared event id — and can never disagree.
|
|
601
|
+
*
|
|
602
|
+
* It is sent as-is, NOT truncated. v1 has always sent the raw order id, and a
|
|
603
|
+
* real order/event id sits well within Google's 64-char limit. Slicing to 64
|
|
604
|
+
* would both silently change v1's long ids and collapse two distinct ids that
|
|
605
|
+
* share a 64-char prefix onto the same dedup key (undercounting). A pathological
|
|
606
|
+
* over-64 id is better rejected visibly by Google than mangled into a collision.
|
|
607
|
+
*/
|
|
608
|
+
const buildTransactionId = (orderId, eventId) => (orderId === null || orderId === void 0 ? void 0 : orderId.toString()) || (eventId === null || eventId === void 0 ? void 0 : eventId.toString()) || '';
|
|
597
609
|
|
|
598
610
|
const getGoogleConsent = (consentData) => {
|
|
599
611
|
const gadsConsent = hasUserConsentForProvider(consentData, 'googleAdsClicks');
|
|
@@ -608,7 +620,7 @@ const getIdentifierValue = (identifier, contentItem) => {
|
|
|
608
620
|
if (!contentItem) {
|
|
609
621
|
return identifierValue;
|
|
610
622
|
}
|
|
611
|
-
identifierValue = identifierValue.replaceAll('{productId}', contentItem.id);
|
|
623
|
+
identifierValue = identifierValue.replaceAll('{productId}', contentItem.id || '');
|
|
612
624
|
identifierValue = identifierValue.replaceAll('{variantId}', contentItem.variantId || '');
|
|
613
625
|
identifierValue = identifierValue.replaceAll('{sku}', contentItem.sku || '');
|
|
614
626
|
return identifierValue;
|
|
@@ -622,7 +634,19 @@ const getConversionLabel = (eventName, manifestVariables) => {
|
|
|
622
634
|
const mapping = mappings.find((mappingItem) => mappingItem.eventName === eventName);
|
|
623
635
|
return mapping === null || mapping === void 0 ? void 0 : mapping.browserConversionLabel;
|
|
624
636
|
};
|
|
625
|
-
|
|
637
|
+
/**
|
|
638
|
+
* Builds the gtag conversion payload.
|
|
639
|
+
*
|
|
640
|
+
* `eventId` matters on v2 only. There, the server sends the same conversion to
|
|
641
|
+
* the same conversion action, and Google deduplicates the pair on
|
|
642
|
+
* `transaction_id` — so every conversion needs one. Purchases have an order id;
|
|
643
|
+
* Lead, SignUp and AddToCart don't, and without a fallback those would count
|
|
644
|
+
* twice. `eventId` is the same value the edge sees on `payload.eventId`, so both
|
|
645
|
+
* sides agree. On v1 there is no eventId fallback — it keeps the raw order id
|
|
646
|
+
* exactly as before the migration, since v1 has no server counterpart to dedupe
|
|
647
|
+
* against.
|
|
648
|
+
*/
|
|
649
|
+
const getEventData = (data, isNewCustomer, eventId) => {
|
|
626
650
|
const eventData = {};
|
|
627
651
|
if (!data) {
|
|
628
652
|
return eventData;
|
|
@@ -633,7 +657,19 @@ const getEventData = (data, isNewCustomer) => {
|
|
|
633
657
|
if (data['currency']) {
|
|
634
658
|
eventData.currency = data['currency'];
|
|
635
659
|
}
|
|
636
|
-
|
|
660
|
+
// `eventId` is passed only on v2 (see tag.ts: `isDataManager ? eventId :
|
|
661
|
+
// undefined`), so its presence marks the v2 path.
|
|
662
|
+
if (eventId !== undefined) {
|
|
663
|
+
// v2: same derivation as the edge (buildTransactionId), sent as-is, so the
|
|
664
|
+
// browser and server dedup keys are always byte-identical.
|
|
665
|
+
const transactionId = buildTransactionId(data['orderId'], eventId);
|
|
666
|
+
if (transactionId) {
|
|
667
|
+
eventData.transaction_id = transactionId;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
else if (data['orderId']) {
|
|
671
|
+
// v1 unchanged: the raw order id exactly as before the migration — no
|
|
672
|
+
// stringify, no eventId fallback — so the dark launch stays v1-identical.
|
|
637
673
|
eventData.transaction_id = data['orderId'];
|
|
638
674
|
}
|
|
639
675
|
if (typeof isNewCustomer === 'boolean') {
|
|
@@ -870,7 +906,7 @@ const initGAds = (ID, consentData, executionContext, consentSkip, sdkUrl) => {
|
|
|
870
906
|
}
|
|
871
907
|
};
|
|
872
908
|
const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
|
|
873
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
909
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
874
910
|
const shouldLoadSDK = ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['loadSDK']) === '1' ||
|
|
875
911
|
((_b = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _b === void 0 ? void 0 : _b['dynamicRemarketingEnabled']) === '1';
|
|
876
912
|
if (typeof window === 'undefined' ||
|
|
@@ -885,7 +921,9 @@ const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
|
|
|
885
921
|
if (resolvedPageUrl) {
|
|
886
922
|
customConfig['page_location'] = resolvedPageUrl;
|
|
887
923
|
}
|
|
888
|
-
|
|
924
|
+
// v2 always drives enhanced conversions through gtag, so it needs this too.
|
|
925
|
+
if (((_e = manifest.variables) === null || _e === void 0 ? void 0 : _e['apiVersion']) === '2' ||
|
|
926
|
+
((_f = manifest.variables) === null || _f === void 0 ? void 0 : _f['enhancedConversionsSetting']) === 'gtag') {
|
|
889
927
|
customConfig['allow_enhanced_conversions'] = true;
|
|
890
928
|
}
|
|
891
929
|
window.dataLayer = window.dataLayer || [];
|
|
@@ -897,7 +935,7 @@ const init = ({ manifest, consentData, executionContext, pageUrl, }) => {
|
|
|
897
935
|
};
|
|
898
936
|
if (!window.google_tag_manager ||
|
|
899
937
|
!window.google_tag_manager[manifest.variables['tagId']]) {
|
|
900
|
-
initGAds(manifest.variables['tagId'], consentData, executionContext, (
|
|
938
|
+
initGAds(manifest.variables['tagId'], consentData, executionContext, (_g = manifest.variables) === null || _g === void 0 ? void 0 : _g['consentSkip'], (_h = manifest.variables) === null || _h === void 0 ? void 0 : _h['sdkUrl']);
|
|
901
939
|
}
|
|
902
940
|
if (window.gtag) {
|
|
903
941
|
window.gtag('config', manifest.variables['tagId'], customConfig);
|
|
@@ -962,11 +1000,11 @@ const getIsNewCustomerFromBrowser = (destination) => {
|
|
|
962
1000
|
return isNewCustomer ? isNewCustomer === 'true' : undefined;
|
|
963
1001
|
};
|
|
964
1002
|
|
|
965
|
-
const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdgeData, }) => {
|
|
1003
|
+
const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl, getEdgeData, }) => {
|
|
966
1004
|
var _a, _b;
|
|
967
1005
|
const result = {
|
|
968
1006
|
isFired: false,
|
|
969
|
-
sdkVersion: "1.
|
|
1007
|
+
sdkVersion: "1.69.0" ,
|
|
970
1008
|
};
|
|
971
1009
|
const tagId = manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'];
|
|
972
1010
|
if (!eventName || !window.gtag || !tagId) {
|
|
@@ -984,14 +1022,23 @@ const tag = ({ data, eventName, manifestVariables, destination, pageUrl, getEdge
|
|
|
984
1022
|
if ((manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1') {
|
|
985
1023
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
986
1024
|
if (conversionLabel) {
|
|
987
|
-
|
|
1025
|
+
const isDataManager = manifestVariables['apiVersion'] === '2';
|
|
1026
|
+
/*
|
|
1027
|
+
* On v2 the browser is the primary source of user data: Google now accepts
|
|
1028
|
+
* user-provided data from the tag, Data Manager and the API at once, so
|
|
1029
|
+
* there is no adjustment upload to attach it server-side. Consent is
|
|
1030
|
+
* handled by Consent Mode — `init` sets ad_user_data/ad_personalization
|
|
1031
|
+
* from the user's consent, and gtag withholds user data when they're denied.
|
|
1032
|
+
*/
|
|
1033
|
+
if ((isDataManager ||
|
|
1034
|
+
manifestVariables['enhancedConversionsSetting'] === 'gtag') &&
|
|
988
1035
|
destination) {
|
|
989
1036
|
window.gtag('set', 'user_data', getUserData(destination));
|
|
990
1037
|
}
|
|
991
1038
|
const cartData = getCartData(manifestVariables, data);
|
|
992
1039
|
const fireConversion = (isNewCustomer) => {
|
|
993
1040
|
var _a;
|
|
994
|
-
const eventData = getEventData(data, isNewCustomer);
|
|
1041
|
+
const eventData = getEventData(data, isNewCustomer, isDataManager ? eventId : undefined);
|
|
995
1042
|
const conversionPayload = {
|
|
996
1043
|
send_to: conversionLabel,
|
|
997
1044
|
...eventData,
|