@jetshop/core 5.8.0 → 5.8.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Tracker } from '../../trackerRegistry';
|
2
2
|
export declare function unSlugify(slug?: string): string;
|
3
|
-
export declare const gtagTracker: ({ trackingId, additionalGtagTrackingIds, currency, useArticleNumberAsId
|
3
|
+
export declare const gtagTracker: ({ trackingId, additionalGtagTrackingIds, currency, useArticleNumberAsId }: {
|
4
4
|
trackingId: string;
|
5
5
|
additionalGtagTrackingIds: string[];
|
6
6
|
currency: string;
|
@@ -5,11 +5,11 @@ export function unSlugify(slug) {
|
|
5
5
|
if (slug) {
|
6
6
|
slug = slug
|
7
7
|
.split('-')
|
8
|
-
.map(
|
8
|
+
.map(part => part.length > 0 ? part[0].toUpperCase() + part.substring(1) : '')
|
9
9
|
.join(' ');
|
10
10
|
slug = slug
|
11
11
|
.split('/')
|
12
|
-
.map(
|
12
|
+
.map(part => part.length > 0 ? part[0].toUpperCase() + part.substring(1) : '')
|
13
13
|
.join('/');
|
14
14
|
}
|
15
15
|
return slug;
|
@@ -26,7 +26,7 @@ function getProductData(product, selectedVariation, useArticleNumberAsId = false
|
|
26
26
|
name: product.name,
|
27
27
|
base_product: product.articleNumber,
|
28
28
|
category: unSlugify((_b = (_a = product === null || product === void 0 ? void 0 : product.canonicalCategory) === null || _a === void 0 ? void 0 : _a.primaryRoute) === null || _b === void 0 ? void 0 : _b.path),
|
29
|
-
brand: getBrand(product)
|
29
|
+
brand: getBrand(product)
|
30
30
|
};
|
31
31
|
}
|
32
32
|
else {
|
@@ -40,28 +40,28 @@ function getProductData(product, selectedVariation, useArticleNumberAsId = false
|
|
40
40
|
name: product.name,
|
41
41
|
base_product: product.articleNumber,
|
42
42
|
category: unSlugify((_d = (_c = product === null || product === void 0 ? void 0 : product.canonicalCategory) === null || _c === void 0 ? void 0 : _c.primaryRoute) === null || _d === void 0 ? void 0 : _d.path),
|
43
|
-
brand: getBrand(product)
|
43
|
+
brand: getBrand(product)
|
44
44
|
};
|
45
45
|
}
|
46
46
|
}
|
47
|
-
export const gtagTracker = ({ trackingId, additionalGtagTrackingIds = [], currency, useArticleNumberAsId = false
|
47
|
+
export const gtagTracker = ({ trackingId, additionalGtagTrackingIds = [], currency, useArticleNumberAsId = false }) => ({
|
48
48
|
name: 'gtag',
|
49
49
|
initBrowser() {
|
50
50
|
const script = `https://www.googletagmanager.com/gtag/js?id=${trackingId}`;
|
51
51
|
const w = window;
|
52
52
|
w.dataLayer = w.dataLayer || [];
|
53
|
-
w.gtag = function gtag(
|
54
|
-
w.dataLayer.push(
|
53
|
+
w.gtag = function gtag() {
|
54
|
+
w.dataLayer.push(arguments); // I'm not sure why but this dosen't work using rest params. Don't change this line
|
55
55
|
};
|
56
56
|
w.gtag('js', new Date());
|
57
57
|
gtag()('config', trackingId, {
|
58
58
|
currency,
|
59
|
-
send_page_view: false
|
59
|
+
send_page_view: false
|
60
60
|
});
|
61
|
-
additionalGtagTrackingIds.forEach(
|
61
|
+
additionalGtagTrackingIds.forEach(id => {
|
62
62
|
gtag()('config', id, {
|
63
63
|
currency,
|
64
|
-
send_page_view: false
|
64
|
+
send_page_view: false
|
65
65
|
});
|
66
66
|
});
|
67
67
|
injectScript({ src: script });
|
@@ -76,7 +76,7 @@ export const gtagTracker = ({ trackingId, additionalGtagTrackingIds = [], curren
|
|
76
76
|
currency,
|
77
77
|
content_type: 'product',
|
78
78
|
items: [productData],
|
79
|
-
eventId
|
79
|
+
eventId
|
80
80
|
});
|
81
81
|
break;
|
82
82
|
case 'view':
|
@@ -84,21 +84,21 @@ export const gtagTracker = ({ trackingId, additionalGtagTrackingIds = [], curren
|
|
84
84
|
currency,
|
85
85
|
items: [productData],
|
86
86
|
non_interaction: true,
|
87
|
-
eventId
|
87
|
+
eventId
|
88
88
|
});
|
89
89
|
break;
|
90
90
|
case 'add':
|
91
91
|
gtag()('event', 'add_to_cart', {
|
92
92
|
currency,
|
93
93
|
items: [productData],
|
94
|
-
eventId
|
94
|
+
eventId
|
95
95
|
});
|
96
96
|
break;
|
97
97
|
case 'remove':
|
98
98
|
gtag()('event', 'remove_from_cart', {
|
99
99
|
currency,
|
100
100
|
items: [productData],
|
101
|
-
eventId
|
101
|
+
eventId
|
102
102
|
});
|
103
103
|
break;
|
104
104
|
default:
|
@@ -107,11 +107,11 @@ export const gtagTracker = ({ trackingId, additionalGtagTrackingIds = [], curren
|
|
107
107
|
}
|
108
108
|
},
|
109
109
|
trackCartCheckout({ cart }, _context, eventId) {
|
110
|
-
const items = cart.items.map(
|
110
|
+
const items = cart.items.map(item => (Object.assign(Object.assign({}, getProductData(item.product, item.variant, useArticleNumberAsId)), { price: item.total.incVat, quantity: item.quantity })));
|
111
111
|
gtag()('event', 'begin_checkout', {
|
112
112
|
currency,
|
113
113
|
items,
|
114
|
-
eventId
|
114
|
+
eventId
|
115
115
|
});
|
116
116
|
},
|
117
117
|
trackPageView({ pathname, title }, _context, eventId) {
|
@@ -119,7 +119,7 @@ export const gtagTracker = ({ trackingId, additionalGtagTrackingIds = [], curren
|
|
119
119
|
currency,
|
120
120
|
page_path: pathname,
|
121
121
|
page_title: title,
|
122
|
-
eventId
|
122
|
+
eventId
|
123
123
|
});
|
124
124
|
},
|
125
125
|
trackList({ listName, products }, _context, eventId) {
|
@@ -131,13 +131,13 @@ export const gtagTracker = ({ trackingId, additionalGtagTrackingIds = [], curren
|
|
131
131
|
currency,
|
132
132
|
items: productData,
|
133
133
|
non_interaction: true,
|
134
|
-
eventId
|
134
|
+
eventId
|
135
135
|
});
|
136
136
|
},
|
137
137
|
trackExperiment({ id, variant }, _context, eventId) {
|
138
138
|
gtag()('config', trackingId, {
|
139
139
|
experiments: [{ id, variant }],
|
140
|
-
eventId
|
140
|
+
eventId
|
141
141
|
});
|
142
142
|
},
|
143
143
|
trackUser({ userId }, _context, eventId) {
|
@@ -153,8 +153,8 @@ export const gtagTracker = ({ trackingId, additionalGtagTrackingIds = [], curren
|
|
153
153
|
gtag()('event', 'add_to_wishlist', {
|
154
154
|
articleNumber,
|
155
155
|
productName,
|
156
|
-
eventId
|
156
|
+
eventId
|
157
157
|
});
|
158
|
-
}
|
158
|
+
}
|
159
159
|
});
|
160
160
|
//# sourceMappingURL=gtag.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"gtag.js","sourceRoot":"","sources":["gtag.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"gtag.js","sourceRoot":"","sources":["gtag.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,oDAAoD,CAAC;AAE9E,MAAM,IAAI,GAAG,GAAG,EAAE,CAAE,MAAc,CAAC,IAAI,CAAC;AAExC,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,IAAI,IAAI,EAAE;QACR,IAAI,GAAG,IAAI;aACR,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,IAAI,CAAC,EAAE,CACV,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CACjE;aACA,IAAI,CAAC,GAAG,CAAC,CAAC;QACb,IAAI,GAAG,IAAI;aACR,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,IAAI,CAAC,EAAE,CACV,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CACjE;aACA,IAAI,CAAC,GAAG,CAAC,CAAC;KACd;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CACrB,OAAgB,EAChB,iBAAiC,EACjC,oBAAoB,GAAG,KAAK;;IAE5B,I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