@blotoutio/providers-google-ads-clicks-sdk 0.61.0 → 0.62.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 +60 -10
- package/index.js +60 -10
- package/index.mjs +60 -10
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -88,18 +88,22 @@ const initGAds = (ID, executionContext) => {
|
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
const init = ({ manifest, executionContext }) => {
|
|
91
|
-
var _a;
|
|
91
|
+
var _a, _b;
|
|
92
92
|
if (!window || !((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['tagId'])) {
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
+
const customConfig = {
|
|
96
|
+
send_page_view: false,
|
|
97
|
+
};
|
|
98
|
+
if (((_b = manifest.variables) === null || _b === void 0 ? void 0 : _b['enhancedConversionsSetting']) === 'gtag') {
|
|
99
|
+
customConfig['allow_enhanced_conversions'] = true;
|
|
100
|
+
}
|
|
95
101
|
if (!window.google_tag_manager ||
|
|
96
102
|
!window.google_tag_manager[manifest.variables['tagId']]) {
|
|
97
103
|
initGAds(manifest.variables['tagId'], executionContext);
|
|
98
104
|
}
|
|
99
105
|
if (window.gtag) {
|
|
100
|
-
window.gtag('config', manifest.variables['tagId'],
|
|
101
|
-
send_page_view: false,
|
|
102
|
-
});
|
|
106
|
+
window.gtag('config', manifest.variables['tagId'], customConfig);
|
|
103
107
|
}
|
|
104
108
|
};
|
|
105
109
|
|
|
@@ -161,7 +165,43 @@ const getCartData = (variables, data) => {
|
|
|
161
165
|
}
|
|
162
166
|
return cartData;
|
|
163
167
|
};
|
|
164
|
-
const
|
|
168
|
+
const getUserData = (destination) => {
|
|
169
|
+
var _a, _b, _c;
|
|
170
|
+
let kv = {};
|
|
171
|
+
const userData = {};
|
|
172
|
+
const address = {};
|
|
173
|
+
try {
|
|
174
|
+
kv =
|
|
175
|
+
(_c = (_b = (_a = JSON.parse(window.sessionStorage.getItem('_workerStoreMultiple') || '{}')) === null || _a === void 0 ? void 0 : _a[destination]) === null || _b === void 0 ? void 0 : _b['kv']) !== null && _c !== void 0 ? _c : {};
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
console.error('Unable to get user data from session storage');
|
|
179
|
+
kv = {};
|
|
180
|
+
}
|
|
181
|
+
if (kv['email']) {
|
|
182
|
+
userData['email'] = kv['email'];
|
|
183
|
+
}
|
|
184
|
+
if (kv['phone']) {
|
|
185
|
+
userData['phone_number'] = kv['phone'];
|
|
186
|
+
}
|
|
187
|
+
if (kv['firstName']) {
|
|
188
|
+
address['first_name'] = kv['firstName'];
|
|
189
|
+
}
|
|
190
|
+
if (kv['lastName']) {
|
|
191
|
+
address['last_name'] = kv['lastName'];
|
|
192
|
+
}
|
|
193
|
+
if (kv['zip']) {
|
|
194
|
+
address['postal_code'] = kv['zip'];
|
|
195
|
+
}
|
|
196
|
+
if (kv['city']) {
|
|
197
|
+
address['city'] = kv['city'];
|
|
198
|
+
}
|
|
199
|
+
if (Object.keys(address).length) {
|
|
200
|
+
userData['address'] = [address];
|
|
201
|
+
}
|
|
202
|
+
return userData;
|
|
203
|
+
};
|
|
204
|
+
const handleTag = ({ data, eventName, manifestVariables, destination, }) => {
|
|
165
205
|
if (!eventName ||
|
|
166
206
|
!window.gtag ||
|
|
167
207
|
!manifestVariables ||
|
|
@@ -169,11 +209,15 @@ const handleTag = ({ data, eventName, manifestVariables, }) => {
|
|
|
169
209
|
return;
|
|
170
210
|
}
|
|
171
211
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
172
|
-
const eventData = getEventData(data);
|
|
173
|
-
const cartData = getCartData(manifestVariables, data);
|
|
174
212
|
if (!conversionLabel) {
|
|
175
213
|
return;
|
|
176
214
|
}
|
|
215
|
+
if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
|
|
216
|
+
destination) {
|
|
217
|
+
window.gtag('set', 'user_data', getUserData(destination));
|
|
218
|
+
}
|
|
219
|
+
const eventData = getEventData(data);
|
|
220
|
+
const cartData = getCartData(manifestVariables, data);
|
|
177
221
|
window.gtag('event', 'conversion', {
|
|
178
222
|
send_to: conversionLabel,
|
|
179
223
|
...eventData,
|
|
@@ -217,14 +261,20 @@ const parseCookies = (cookie) => {
|
|
|
217
261
|
}));
|
|
218
262
|
};
|
|
219
263
|
|
|
220
|
-
const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
264
|
+
const tag = ({ data, eventName, manifestVariables, eventId, destination, }) => {
|
|
221
265
|
const isLoaded = window && window.gtag && !!getCookieValue('_gcl_au');
|
|
222
266
|
if (isLoaded) {
|
|
223
|
-
handleTag({
|
|
267
|
+
handleTag({
|
|
268
|
+
data,
|
|
269
|
+
eventName,
|
|
270
|
+
manifestVariables,
|
|
271
|
+
eventId,
|
|
272
|
+
destination,
|
|
273
|
+
});
|
|
224
274
|
}
|
|
225
275
|
return {
|
|
226
276
|
loaded: isLoaded,
|
|
227
|
-
sdkVersion: "0.
|
|
277
|
+
sdkVersion: "0.62.0" ,
|
|
228
278
|
};
|
|
229
279
|
};
|
|
230
280
|
|
package/index.js
CHANGED
|
@@ -89,18 +89,22 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
const init = ({ manifest, executionContext }) => {
|
|
92
|
-
var _a;
|
|
92
|
+
var _a, _b;
|
|
93
93
|
if (!window || !((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['tagId'])) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
+
const customConfig = {
|
|
97
|
+
send_page_view: false,
|
|
98
|
+
};
|
|
99
|
+
if (((_b = manifest.variables) === null || _b === void 0 ? void 0 : _b['enhancedConversionsSetting']) === 'gtag') {
|
|
100
|
+
customConfig['allow_enhanced_conversions'] = true;
|
|
101
|
+
}
|
|
96
102
|
if (!window.google_tag_manager ||
|
|
97
103
|
!window.google_tag_manager[manifest.variables['tagId']]) {
|
|
98
104
|
initGAds(manifest.variables['tagId'], executionContext);
|
|
99
105
|
}
|
|
100
106
|
if (window.gtag) {
|
|
101
|
-
window.gtag('config', manifest.variables['tagId'],
|
|
102
|
-
send_page_view: false,
|
|
103
|
-
});
|
|
107
|
+
window.gtag('config', manifest.variables['tagId'], customConfig);
|
|
104
108
|
}
|
|
105
109
|
};
|
|
106
110
|
|
|
@@ -162,7 +166,43 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
162
166
|
}
|
|
163
167
|
return cartData;
|
|
164
168
|
};
|
|
165
|
-
const
|
|
169
|
+
const getUserData = (destination) => {
|
|
170
|
+
var _a, _b, _c;
|
|
171
|
+
let kv = {};
|
|
172
|
+
const userData = {};
|
|
173
|
+
const address = {};
|
|
174
|
+
try {
|
|
175
|
+
kv =
|
|
176
|
+
(_c = (_b = (_a = JSON.parse(window.sessionStorage.getItem('_workerStoreMultiple') || '{}')) === null || _a === void 0 ? void 0 : _a[destination]) === null || _b === void 0 ? void 0 : _b['kv']) !== null && _c !== void 0 ? _c : {};
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
console.error('Unable to get user data from session storage');
|
|
180
|
+
kv = {};
|
|
181
|
+
}
|
|
182
|
+
if (kv['email']) {
|
|
183
|
+
userData['email'] = kv['email'];
|
|
184
|
+
}
|
|
185
|
+
if (kv['phone']) {
|
|
186
|
+
userData['phone_number'] = kv['phone'];
|
|
187
|
+
}
|
|
188
|
+
if (kv['firstName']) {
|
|
189
|
+
address['first_name'] = kv['firstName'];
|
|
190
|
+
}
|
|
191
|
+
if (kv['lastName']) {
|
|
192
|
+
address['last_name'] = kv['lastName'];
|
|
193
|
+
}
|
|
194
|
+
if (kv['zip']) {
|
|
195
|
+
address['postal_code'] = kv['zip'];
|
|
196
|
+
}
|
|
197
|
+
if (kv['city']) {
|
|
198
|
+
address['city'] = kv['city'];
|
|
199
|
+
}
|
|
200
|
+
if (Object.keys(address).length) {
|
|
201
|
+
userData['address'] = [address];
|
|
202
|
+
}
|
|
203
|
+
return userData;
|
|
204
|
+
};
|
|
205
|
+
const handleTag = ({ data, eventName, manifestVariables, destination, }) => {
|
|
166
206
|
if (!eventName ||
|
|
167
207
|
!window.gtag ||
|
|
168
208
|
!manifestVariables ||
|
|
@@ -170,11 +210,15 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
170
210
|
return;
|
|
171
211
|
}
|
|
172
212
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
173
|
-
const eventData = getEventData(data);
|
|
174
|
-
const cartData = getCartData(manifestVariables, data);
|
|
175
213
|
if (!conversionLabel) {
|
|
176
214
|
return;
|
|
177
215
|
}
|
|
216
|
+
if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
|
|
217
|
+
destination) {
|
|
218
|
+
window.gtag('set', 'user_data', getUserData(destination));
|
|
219
|
+
}
|
|
220
|
+
const eventData = getEventData(data);
|
|
221
|
+
const cartData = getCartData(manifestVariables, data);
|
|
178
222
|
window.gtag('event', 'conversion', {
|
|
179
223
|
send_to: conversionLabel,
|
|
180
224
|
...eventData,
|
|
@@ -218,14 +262,20 @@ var ProvidersGoogleAdsClicksSdk = (function () {
|
|
|
218
262
|
}));
|
|
219
263
|
};
|
|
220
264
|
|
|
221
|
-
const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
265
|
+
const tag = ({ data, eventName, manifestVariables, eventId, destination, }) => {
|
|
222
266
|
const isLoaded = window && window.gtag && !!getCookieValue('_gcl_au');
|
|
223
267
|
if (isLoaded) {
|
|
224
|
-
handleTag({
|
|
268
|
+
handleTag({
|
|
269
|
+
data,
|
|
270
|
+
eventName,
|
|
271
|
+
manifestVariables,
|
|
272
|
+
eventId,
|
|
273
|
+
destination,
|
|
274
|
+
});
|
|
225
275
|
}
|
|
226
276
|
return {
|
|
227
277
|
loaded: isLoaded,
|
|
228
|
-
sdkVersion: "0.
|
|
278
|
+
sdkVersion: "0.62.0" ,
|
|
229
279
|
};
|
|
230
280
|
};
|
|
231
281
|
|
package/index.mjs
CHANGED
|
@@ -86,18 +86,22 @@ const initGAds = (ID, executionContext) => {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
const init = ({ manifest, executionContext }) => {
|
|
89
|
-
var _a;
|
|
89
|
+
var _a, _b;
|
|
90
90
|
if (!window || !((_a = manifest === null || manifest === void 0 ? void 0 : manifest.variables) === null || _a === void 0 ? void 0 : _a['tagId'])) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
+
const customConfig = {
|
|
94
|
+
send_page_view: false,
|
|
95
|
+
};
|
|
96
|
+
if (((_b = manifest.variables) === null || _b === void 0 ? void 0 : _b['enhancedConversionsSetting']) === 'gtag') {
|
|
97
|
+
customConfig['allow_enhanced_conversions'] = true;
|
|
98
|
+
}
|
|
93
99
|
if (!window.google_tag_manager ||
|
|
94
100
|
!window.google_tag_manager[manifest.variables['tagId']]) {
|
|
95
101
|
initGAds(manifest.variables['tagId'], executionContext);
|
|
96
102
|
}
|
|
97
103
|
if (window.gtag) {
|
|
98
|
-
window.gtag('config', manifest.variables['tagId'],
|
|
99
|
-
send_page_view: false,
|
|
100
|
-
});
|
|
104
|
+
window.gtag('config', manifest.variables['tagId'], customConfig);
|
|
101
105
|
}
|
|
102
106
|
};
|
|
103
107
|
|
|
@@ -159,7 +163,43 @@ const getCartData = (variables, data) => {
|
|
|
159
163
|
}
|
|
160
164
|
return cartData;
|
|
161
165
|
};
|
|
162
|
-
const
|
|
166
|
+
const getUserData = (destination) => {
|
|
167
|
+
var _a, _b, _c;
|
|
168
|
+
let kv = {};
|
|
169
|
+
const userData = {};
|
|
170
|
+
const address = {};
|
|
171
|
+
try {
|
|
172
|
+
kv =
|
|
173
|
+
(_c = (_b = (_a = JSON.parse(window.sessionStorage.getItem('_workerStoreMultiple') || '{}')) === null || _a === void 0 ? void 0 : _a[destination]) === null || _b === void 0 ? void 0 : _b['kv']) !== null && _c !== void 0 ? _c : {};
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
console.error('Unable to get user data from session storage');
|
|
177
|
+
kv = {};
|
|
178
|
+
}
|
|
179
|
+
if (kv['email']) {
|
|
180
|
+
userData['email'] = kv['email'];
|
|
181
|
+
}
|
|
182
|
+
if (kv['phone']) {
|
|
183
|
+
userData['phone_number'] = kv['phone'];
|
|
184
|
+
}
|
|
185
|
+
if (kv['firstName']) {
|
|
186
|
+
address['first_name'] = kv['firstName'];
|
|
187
|
+
}
|
|
188
|
+
if (kv['lastName']) {
|
|
189
|
+
address['last_name'] = kv['lastName'];
|
|
190
|
+
}
|
|
191
|
+
if (kv['zip']) {
|
|
192
|
+
address['postal_code'] = kv['zip'];
|
|
193
|
+
}
|
|
194
|
+
if (kv['city']) {
|
|
195
|
+
address['city'] = kv['city'];
|
|
196
|
+
}
|
|
197
|
+
if (Object.keys(address).length) {
|
|
198
|
+
userData['address'] = [address];
|
|
199
|
+
}
|
|
200
|
+
return userData;
|
|
201
|
+
};
|
|
202
|
+
const handleTag = ({ data, eventName, manifestVariables, destination, }) => {
|
|
163
203
|
if (!eventName ||
|
|
164
204
|
!window.gtag ||
|
|
165
205
|
!manifestVariables ||
|
|
@@ -167,11 +207,15 @@ const handleTag = ({ data, eventName, manifestVariables, }) => {
|
|
|
167
207
|
return;
|
|
168
208
|
}
|
|
169
209
|
const conversionLabel = getConversionLabel(eventName, manifestVariables);
|
|
170
|
-
const eventData = getEventData(data);
|
|
171
|
-
const cartData = getCartData(manifestVariables, data);
|
|
172
210
|
if (!conversionLabel) {
|
|
173
211
|
return;
|
|
174
212
|
}
|
|
213
|
+
if (manifestVariables['enhancedConversionsSetting'] === 'gtag' &&
|
|
214
|
+
destination) {
|
|
215
|
+
window.gtag('set', 'user_data', getUserData(destination));
|
|
216
|
+
}
|
|
217
|
+
const eventData = getEventData(data);
|
|
218
|
+
const cartData = getCartData(manifestVariables, data);
|
|
175
219
|
window.gtag('event', 'conversion', {
|
|
176
220
|
send_to: conversionLabel,
|
|
177
221
|
...eventData,
|
|
@@ -215,14 +259,20 @@ const parseCookies = (cookie) => {
|
|
|
215
259
|
}));
|
|
216
260
|
};
|
|
217
261
|
|
|
218
|
-
const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
262
|
+
const tag = ({ data, eventName, manifestVariables, eventId, destination, }) => {
|
|
219
263
|
const isLoaded = window && window.gtag && !!getCookieValue('_gcl_au');
|
|
220
264
|
if (isLoaded) {
|
|
221
|
-
handleTag({
|
|
265
|
+
handleTag({
|
|
266
|
+
data,
|
|
267
|
+
eventName,
|
|
268
|
+
manifestVariables,
|
|
269
|
+
eventId,
|
|
270
|
+
destination,
|
|
271
|
+
});
|
|
222
272
|
}
|
|
223
273
|
return {
|
|
224
274
|
loaded: isLoaded,
|
|
225
|
-
sdkVersion: "0.
|
|
275
|
+
sdkVersion: "0.62.0" ,
|
|
226
276
|
};
|
|
227
277
|
};
|
|
228
278
|
|