@akinon/pz-b2b 1.21.0-rc.5 → 1.21.0-rc.7
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/utils/gtm.ts +17 -12
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/utils/gtm.ts
CHANGED
@@ -1,21 +1,16 @@
|
|
1
1
|
'use client';
|
2
2
|
|
3
|
-
import { GTMEvent, Product } from '@akinon/next/types';
|
3
|
+
import { GA4EventParams, GTMEvent, Product } from '@akinon/next/types';
|
4
4
|
|
5
5
|
export const pushCartView = (
|
6
6
|
products: Pick<Product, 'name' | 'pk' | 'price'>[]
|
7
7
|
) => {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
id: product.pk,
|
15
|
-
price: product.price
|
16
|
-
}))
|
17
|
-
},
|
18
|
-
event: 'eeCheckout'
|
8
|
+
pushEventGA4('view_cart', {
|
9
|
+
items: products?.map((product) => ({
|
10
|
+
item_name: product.name,
|
11
|
+
item_id: product.pk,
|
12
|
+
price: product.price
|
13
|
+
}))
|
19
14
|
});
|
20
15
|
};
|
21
16
|
|
@@ -24,3 +19,13 @@ export const pushEvent = (event: GTMEvent) => {
|
|
24
19
|
|
25
20
|
window.dataLayer.push({ Category, Value, ...rest });
|
26
21
|
};
|
22
|
+
|
23
|
+
export const pushEventGA4 = (
|
24
|
+
eventAction: string,
|
25
|
+
eventParams: GA4EventParams
|
26
|
+
) => {
|
27
|
+
window.dataLayer.push({
|
28
|
+
event: eventAction,
|
29
|
+
...eventParams
|
30
|
+
});
|
31
|
+
};
|