@blotoutio/providers-google-ads-clicks-sdk 1.70.0 → 1.70.2
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 +48 -4
- package/index.js +48 -4
- package/index.mjs +48 -4
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -682,6 +682,8 @@ const getEventData = (data, isNewCustomer, eventId) => {
|
|
|
682
682
|
}
|
|
683
683
|
return eventData;
|
|
684
684
|
};
|
|
685
|
+
// aw_merchant_id and the id/price/quantity items below only report as cart data
|
|
686
|
+
// on Google's `purchase` event, which is why tag.ts renames Purchase.
|
|
685
687
|
const getCartData = (variables, data) => {
|
|
686
688
|
const cartData = {};
|
|
687
689
|
const merchantId = parseInt(variables['merchantId']);
|
|
@@ -1012,7 +1014,7 @@ const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl
|
|
|
1012
1014
|
var _a, _b;
|
|
1013
1015
|
const result = {
|
|
1014
1016
|
isFired: false,
|
|
1015
|
-
sdkVersion: "1.70.
|
|
1017
|
+
sdkVersion: "1.70.2" ,
|
|
1016
1018
|
};
|
|
1017
1019
|
const tagId = manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'];
|
|
1018
1020
|
if (!eventName || !window.gtag || !tagId) {
|
|
@@ -1020,7 +1022,18 @@ const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl
|
|
|
1020
1022
|
}
|
|
1021
1023
|
const shouldLoadSDK = (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1' ||
|
|
1022
1024
|
(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['dynamicRemarketingEnabled']) === '1';
|
|
1023
|
-
|
|
1025
|
+
const isDataManager = (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['apiVersion']) === '2';
|
|
1026
|
+
/*
|
|
1027
|
+
* v1 has to know gtag.js actually loaded. Google does no cross-source dedup
|
|
1028
|
+
* there, so the hybrid flow sends each conversion from one side only: the edge
|
|
1029
|
+
* skips its server conversion whenever isFired is true, and a queued event that
|
|
1030
|
+
* never flushed would be lost on both paths. v2 removes that reason — both
|
|
1031
|
+
* sides always send and Google dedups on transactionId — so we hand the event
|
|
1032
|
+
* to the gtag queue and let it flush whenever gtag.js arrives, rather than
|
|
1033
|
+
* dropping every conversion that lands while the script is still in flight.
|
|
1034
|
+
*/
|
|
1035
|
+
if (!shouldLoadSDK ||
|
|
1036
|
+
(!isDataManager && !((_a = window.google_tag_manager) === null || _a === void 0 ? void 0 : _a[tagId]))) {
|
|
1024
1037
|
return result;
|
|
1025
1038
|
}
|
|
1026
1039
|
const resolvedPageUrl = pageUrl || ((_b = window.location) === null || _b === void 0 ? void 0 : _b.href);
|
|
@@ -1028,9 +1041,23 @@ const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl
|
|
|
1028
1041
|
sendDynamicRemarketingEvent(eventName, manifestVariables, data, resolvedPageUrl);
|
|
1029
1042
|
// Fire conversion event if loadSDK is enabled and conversion label exists
|
|
1030
1043
|
if ((manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1') {
|
|
1044
|
+
/*
|
|
1045
|
+
* No label means the row is mapped to an import-for-clicks conversion
|
|
1046
|
+
* action, which has no tag snippet and so nothing for gtag to send to. Those
|
|
1047
|
+
* rows are server-only by design (they are how a v1 server-only mapping
|
|
1048
|
+
* migrates to v2), so skip the browser conversion and leave the upload to
|
|
1049
|
+
* the edge. Dynamic remarketing above is keyed to the tag id, not a label,
|
|
1050
|
+
* and still fires.
|
|
1051
|
+
*/
|
|
1031
1052
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
1032
1053
|
if (conversionLabel) {
|
|
1033
|
-
|
|
1054
|
+
/*
|
|
1055
|
+
* On v2 the browser is the primary source of user data: Google now accepts
|
|
1056
|
+
* user-provided data from the tag, Data Manager and the API at once, so
|
|
1057
|
+
* there is no adjustment upload to attach it server-side. Consent is
|
|
1058
|
+
* handled by Consent Mode — `init` sets ad_user_data/ad_personalization
|
|
1059
|
+
* from the user's consent, and gtag withholds user data when they're denied.
|
|
1060
|
+
*/
|
|
1034
1061
|
// On unless a super admin turns it off for the channel — setting user data
|
|
1035
1062
|
// here appears to cost the account's v1 conversion actions their enhanced
|
|
1036
1063
|
// conversions coverage. v1 keeps following the customer's own EC setting.
|
|
@@ -1060,7 +1087,24 @@ const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl
|
|
|
1060
1087
|
if (resolvedPageUrl) {
|
|
1061
1088
|
conversionPayload['page_location'] = resolvedPageUrl;
|
|
1062
1089
|
}
|
|
1063
|
-
|
|
1090
|
+
/*
|
|
1091
|
+
* Purchase goes out as `purchase`, which is the event name Google's
|
|
1092
|
+
* conversion-with-cart-data spec requires for the aw_merchant_id/items
|
|
1093
|
+
* payload getCartData builds. Every other event keeps `conversion`.
|
|
1094
|
+
*
|
|
1095
|
+
* v2 only for now. v1 channels keep firing `conversion` so the rename
|
|
1096
|
+
* rolls out with the Data Manager migration instead of changing every
|
|
1097
|
+
* live account at once. Widen this once v2 has proved it out.
|
|
1098
|
+
*
|
|
1099
|
+
* The rename moves nothing else: send_to picks the conversion action, so
|
|
1100
|
+
* the same label credits the same action it always did, and
|
|
1101
|
+
* transaction_id, value and currency are untouched. But `purchase` is a
|
|
1102
|
+
* standard gtag name, unlike `conversion`, so a push without send_to
|
|
1103
|
+
* would fan out to every destination on the page including a GA4 config.
|
|
1104
|
+
* The conversionLabel guard above is what keeps send_to set on all of
|
|
1105
|
+
* these. Do not fire this event outside that guard.
|
|
1106
|
+
*/
|
|
1107
|
+
(_a = window.gtag) === null || _a === void 0 ? void 0 : _a.call(window, 'event', isDataManager && eventName === 'Purchase' ? 'purchase' : 'conversion', conversionPayload);
|
|
1064
1108
|
};
|
|
1065
1109
|
if (eventName === 'Purchase' &&
|
|
1066
1110
|
(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1') {
|
package/index.js
CHANGED
|
@@ -683,6 +683,8 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
683
683
|
}
|
|
684
684
|
return eventData;
|
|
685
685
|
};
|
|
686
|
+
// aw_merchant_id and the id/price/quantity items below only report as cart data
|
|
687
|
+
// on Google's `purchase` event, which is why tag.ts renames Purchase.
|
|
686
688
|
const getCartData = (variables, data) => {
|
|
687
689
|
const cartData = {};
|
|
688
690
|
const merchantId = parseInt(variables['merchantId']);
|
|
@@ -1013,7 +1015,7 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
1013
1015
|
var _a, _b;
|
|
1014
1016
|
const result = {
|
|
1015
1017
|
isFired: false,
|
|
1016
|
-
sdkVersion: "1.70.
|
|
1018
|
+
sdkVersion: "1.70.2" ,
|
|
1017
1019
|
};
|
|
1018
1020
|
const tagId = manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'];
|
|
1019
1021
|
if (!eventName || !window.gtag || !tagId) {
|
|
@@ -1021,7 +1023,18 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
1021
1023
|
}
|
|
1022
1024
|
const shouldLoadSDK = (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1' ||
|
|
1023
1025
|
(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['dynamicRemarketingEnabled']) === '1';
|
|
1024
|
-
|
|
1026
|
+
const isDataManager = (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['apiVersion']) === '2';
|
|
1027
|
+
/*
|
|
1028
|
+
* v1 has to know gtag.js actually loaded. Google does no cross-source dedup
|
|
1029
|
+
* there, so the hybrid flow sends each conversion from one side only: the edge
|
|
1030
|
+
* skips its server conversion whenever isFired is true, and a queued event that
|
|
1031
|
+
* never flushed would be lost on both paths. v2 removes that reason — both
|
|
1032
|
+
* sides always send and Google dedups on transactionId — so we hand the event
|
|
1033
|
+
* to the gtag queue and let it flush whenever gtag.js arrives, rather than
|
|
1034
|
+
* dropping every conversion that lands while the script is still in flight.
|
|
1035
|
+
*/
|
|
1036
|
+
if (!shouldLoadSDK ||
|
|
1037
|
+
(!isDataManager && !((_a = window.google_tag_manager) === null || _a === void 0 ? void 0 : _a[tagId]))) {
|
|
1025
1038
|
return result;
|
|
1026
1039
|
}
|
|
1027
1040
|
const resolvedPageUrl = pageUrl || ((_b = window.location) === null || _b === void 0 ? void 0 : _b.href);
|
|
@@ -1029,9 +1042,23 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
1029
1042
|
sendDynamicRemarketingEvent(eventName, manifestVariables, data, resolvedPageUrl);
|
|
1030
1043
|
// Fire conversion event if loadSDK is enabled and conversion label exists
|
|
1031
1044
|
if ((manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1') {
|
|
1045
|
+
/*
|
|
1046
|
+
* No label means the row is mapped to an import-for-clicks conversion
|
|
1047
|
+
* action, which has no tag snippet and so nothing for gtag to send to. Those
|
|
1048
|
+
* rows are server-only by design (they are how a v1 server-only mapping
|
|
1049
|
+
* migrates to v2), so skip the browser conversion and leave the upload to
|
|
1050
|
+
* the edge. Dynamic remarketing above is keyed to the tag id, not a label,
|
|
1051
|
+
* and still fires.
|
|
1052
|
+
*/
|
|
1032
1053
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
1033
1054
|
if (conversionLabel) {
|
|
1034
|
-
|
|
1055
|
+
/*
|
|
1056
|
+
* On v2 the browser is the primary source of user data: Google now accepts
|
|
1057
|
+
* user-provided data from the tag, Data Manager and the API at once, so
|
|
1058
|
+
* there is no adjustment upload to attach it server-side. Consent is
|
|
1059
|
+
* handled by Consent Mode — `init` sets ad_user_data/ad_personalization
|
|
1060
|
+
* from the user's consent, and gtag withholds user data when they're denied.
|
|
1061
|
+
*/
|
|
1035
1062
|
// On unless a super admin turns it off for the channel — setting user data
|
|
1036
1063
|
// here appears to cost the account's v1 conversion actions their enhanced
|
|
1037
1064
|
// conversions coverage. v1 keeps following the customer's own EC setting.
|
|
@@ -1061,7 +1088,24 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
1061
1088
|
if (resolvedPageUrl) {
|
|
1062
1089
|
conversionPayload['page_location'] = resolvedPageUrl;
|
|
1063
1090
|
}
|
|
1064
|
-
|
|
1091
|
+
/*
|
|
1092
|
+
* Purchase goes out as `purchase`, which is the event name Google's
|
|
1093
|
+
* conversion-with-cart-data spec requires for the aw_merchant_id/items
|
|
1094
|
+
* payload getCartData builds. Every other event keeps `conversion`.
|
|
1095
|
+
*
|
|
1096
|
+
* v2 only for now. v1 channels keep firing `conversion` so the rename
|
|
1097
|
+
* rolls out with the Data Manager migration instead of changing every
|
|
1098
|
+
* live account at once. Widen this once v2 has proved it out.
|
|
1099
|
+
*
|
|
1100
|
+
* The rename moves nothing else: send_to picks the conversion action, so
|
|
1101
|
+
* the same label credits the same action it always did, and
|
|
1102
|
+
* transaction_id, value and currency are untouched. But `purchase` is a
|
|
1103
|
+
* standard gtag name, unlike `conversion`, so a push without send_to
|
|
1104
|
+
* would fan out to every destination on the page including a GA4 config.
|
|
1105
|
+
* The conversionLabel guard above is what keeps send_to set on all of
|
|
1106
|
+
* these. Do not fire this event outside that guard.
|
|
1107
|
+
*/
|
|
1108
|
+
(_a = window.gtag) === null || _a === void 0 ? void 0 : _a.call(window, 'event', isDataManager && eventName === 'Purchase' ? 'purchase' : 'conversion', conversionPayload);
|
|
1065
1109
|
};
|
|
1066
1110
|
if (eventName === 'Purchase' &&
|
|
1067
1111
|
(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1') {
|
package/index.mjs
CHANGED
|
@@ -680,6 +680,8 @@ const getEventData = (data, isNewCustomer, eventId) => {
|
|
|
680
680
|
}
|
|
681
681
|
return eventData;
|
|
682
682
|
};
|
|
683
|
+
// aw_merchant_id and the id/price/quantity items below only report as cart data
|
|
684
|
+
// on Google's `purchase` event, which is why tag.ts renames Purchase.
|
|
683
685
|
const getCartData = (variables, data) => {
|
|
684
686
|
const cartData = {};
|
|
685
687
|
const merchantId = parseInt(variables['merchantId']);
|
|
@@ -1010,7 +1012,7 @@ const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl
|
|
|
1010
1012
|
var _a, _b;
|
|
1011
1013
|
const result = {
|
|
1012
1014
|
isFired: false,
|
|
1013
|
-
sdkVersion: "1.70.
|
|
1015
|
+
sdkVersion: "1.70.2" ,
|
|
1014
1016
|
};
|
|
1015
1017
|
const tagId = manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['tagId'];
|
|
1016
1018
|
if (!eventName || !window.gtag || !tagId) {
|
|
@@ -1018,7 +1020,18 @@ const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl
|
|
|
1018
1020
|
}
|
|
1019
1021
|
const shouldLoadSDK = (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1' ||
|
|
1020
1022
|
(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['dynamicRemarketingEnabled']) === '1';
|
|
1021
|
-
|
|
1023
|
+
const isDataManager = (manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['apiVersion']) === '2';
|
|
1024
|
+
/*
|
|
1025
|
+
* v1 has to know gtag.js actually loaded. Google does no cross-source dedup
|
|
1026
|
+
* there, so the hybrid flow sends each conversion from one side only: the edge
|
|
1027
|
+
* skips its server conversion whenever isFired is true, and a queued event that
|
|
1028
|
+
* never flushed would be lost on both paths. v2 removes that reason — both
|
|
1029
|
+
* sides always send and Google dedups on transactionId — so we hand the event
|
|
1030
|
+
* to the gtag queue and let it flush whenever gtag.js arrives, rather than
|
|
1031
|
+
* dropping every conversion that lands while the script is still in flight.
|
|
1032
|
+
*/
|
|
1033
|
+
if (!shouldLoadSDK ||
|
|
1034
|
+
(!isDataManager && !((_a = window.google_tag_manager) === null || _a === void 0 ? void 0 : _a[tagId]))) {
|
|
1022
1035
|
return result;
|
|
1023
1036
|
}
|
|
1024
1037
|
const resolvedPageUrl = pageUrl || ((_b = window.location) === null || _b === void 0 ? void 0 : _b.href);
|
|
@@ -1026,9 +1039,23 @@ const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl
|
|
|
1026
1039
|
sendDynamicRemarketingEvent(eventName, manifestVariables, data, resolvedPageUrl);
|
|
1027
1040
|
// Fire conversion event if loadSDK is enabled and conversion label exists
|
|
1028
1041
|
if ((manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['loadSDK']) === '1') {
|
|
1042
|
+
/*
|
|
1043
|
+
* No label means the row is mapped to an import-for-clicks conversion
|
|
1044
|
+
* action, which has no tag snippet and so nothing for gtag to send to. Those
|
|
1045
|
+
* rows are server-only by design (they are how a v1 server-only mapping
|
|
1046
|
+
* migrates to v2), so skip the browser conversion and leave the upload to
|
|
1047
|
+
* the edge. Dynamic remarketing above is keyed to the tag id, not a label,
|
|
1048
|
+
* and still fires.
|
|
1049
|
+
*/
|
|
1029
1050
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
1030
1051
|
if (conversionLabel) {
|
|
1031
|
-
|
|
1052
|
+
/*
|
|
1053
|
+
* On v2 the browser is the primary source of user data: Google now accepts
|
|
1054
|
+
* user-provided data from the tag, Data Manager and the API at once, so
|
|
1055
|
+
* there is no adjustment upload to attach it server-side. Consent is
|
|
1056
|
+
* handled by Consent Mode — `init` sets ad_user_data/ad_personalization
|
|
1057
|
+
* from the user's consent, and gtag withholds user data when they're denied.
|
|
1058
|
+
*/
|
|
1032
1059
|
// On unless a super admin turns it off for the channel — setting user data
|
|
1033
1060
|
// here appears to cost the account's v1 conversion actions their enhanced
|
|
1034
1061
|
// conversions coverage. v1 keeps following the customer's own EC setting.
|
|
@@ -1058,7 +1085,24 @@ const tag = ({ data, eventName, eventId, manifestVariables, destination, pageUrl
|
|
|
1058
1085
|
if (resolvedPageUrl) {
|
|
1059
1086
|
conversionPayload['page_location'] = resolvedPageUrl;
|
|
1060
1087
|
}
|
|
1061
|
-
|
|
1088
|
+
/*
|
|
1089
|
+
* Purchase goes out as `purchase`, which is the event name Google's
|
|
1090
|
+
* conversion-with-cart-data spec requires for the aw_merchant_id/items
|
|
1091
|
+
* payload getCartData builds. Every other event keeps `conversion`.
|
|
1092
|
+
*
|
|
1093
|
+
* v2 only for now. v1 channels keep firing `conversion` so the rename
|
|
1094
|
+
* rolls out with the Data Manager migration instead of changing every
|
|
1095
|
+
* live account at once. Widen this once v2 has proved it out.
|
|
1096
|
+
*
|
|
1097
|
+
* The rename moves nothing else: send_to picks the conversion action, so
|
|
1098
|
+
* the same label credits the same action it always did, and
|
|
1099
|
+
* transaction_id, value and currency are untouched. But `purchase` is a
|
|
1100
|
+
* standard gtag name, unlike `conversion`, so a push without send_to
|
|
1101
|
+
* would fan out to every destination on the page including a GA4 config.
|
|
1102
|
+
* The conversionLabel guard above is what keeps send_to set on all of
|
|
1103
|
+
* these. Do not fire this event outside that guard.
|
|
1104
|
+
*/
|
|
1105
|
+
(_a = window.gtag) === null || _a === void 0 ? void 0 : _a.call(window, 'event', isDataManager && eventName === 'Purchase' ? 'purchase' : 'conversion', conversionPayload);
|
|
1062
1106
|
};
|
|
1063
1107
|
if (eventName === 'Purchase' &&
|
|
1064
1108
|
(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['newCustomerReportingEnabled']) === '1') {
|