@eventlook/sdk 1.4.6 → 1.4.8
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/dist/cjs/form/PaymentSuccess.js +39 -2
- package/dist/cjs/form/PaymentSuccess.js.map +1 -1
- package/dist/cjs/form/TicketForm.js +1 -1
- package/dist/cjs/form/TicketForm.js.map +1 -1
- package/dist/cjs/utils/gtm.js +20 -0
- package/dist/cjs/utils/gtm.js.map +1 -1
- package/dist/esm/form/PaymentSuccess.js +39 -2
- package/dist/esm/form/PaymentSuccess.js.map +1 -1
- package/dist/esm/form/TicketForm.js +1 -1
- package/dist/esm/form/TicketForm.js.map +1 -1
- package/dist/esm/utils/gtm.js +19 -1
- package/dist/esm/utils/gtm.js.map +1 -1
- package/dist/types/form/PaymentSuccess.d.ts +2 -0
- package/dist/types/utils/gtm.d.ts +3 -1
- package/dist/types/utils/types/gtm.type.d.ts +5 -0
- package/dist/types/utils/types/order.type.d.ts +1 -0
- package/package.json +1 -1
- package/src/form/PaymentSuccess.tsx +46 -3
- package/src/form/TicketForm.tsx +1 -1
- package/src/utils/gtm.ts +29 -0
- package/src/utils/types/gtm.type.ts +6 -0
- package/src/utils/types/order.type.ts +1 -0
package/src/utils/gtm.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
ISelectItem,
|
|
18
18
|
IAddToCart,
|
|
19
19
|
IRemoveFromCart,
|
|
20
|
+
IPurchasePaid,
|
|
20
21
|
} from '@utils/types/gtm.type';
|
|
21
22
|
import { UserIpCookie } from '@utils/data/cookie';
|
|
22
23
|
import { IUser } from '@utils/types/user.type';
|
|
@@ -225,6 +226,34 @@ export const gtmPurchase = (
|
|
|
225
226
|
return pageEvent;
|
|
226
227
|
};
|
|
227
228
|
|
|
229
|
+
export const getGtmPurchasePaid = (
|
|
230
|
+
item: IEcommercePurchase | null,
|
|
231
|
+
pixels?: IPixels,
|
|
232
|
+
userData?: IUserData
|
|
233
|
+
) => {
|
|
234
|
+
const userIp = Cookies.get(UserIpCookie);
|
|
235
|
+
const pageEvent: IPurchasePaid & IPixels = {
|
|
236
|
+
event: 'purchase_paid',
|
|
237
|
+
fb_pixel_id: pixels?.fb_pixel_id || '',
|
|
238
|
+
tiktok_pixel_id: pixels?.tiktok_pixel_id || '',
|
|
239
|
+
ecommerce: item,
|
|
240
|
+
user_data: userData || null,
|
|
241
|
+
ip: userIp || '',
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
return pageEvent;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const gtmPurchasePaid = (
|
|
248
|
+
item: IEcommercePurchase | null,
|
|
249
|
+
pixels?: IPixels,
|
|
250
|
+
userData?: IUserData
|
|
251
|
+
) => {
|
|
252
|
+
const pageEvent = getGtmPurchasePaid(item, pixels, userData);
|
|
253
|
+
if (isBrowser() && window.dataLayer) setTimeout(() => window.dataLayer.push(pageEvent), 500);
|
|
254
|
+
return pageEvent;
|
|
255
|
+
};
|
|
256
|
+
|
|
228
257
|
export const mapUserToUserData = (user: IUser) => ({
|
|
229
258
|
em: user.email,
|
|
230
259
|
ph: user.phone,
|
|
@@ -96,6 +96,12 @@ export interface IPurchase extends IBase {
|
|
|
96
96
|
user_data: IUserData | null;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
export interface IPurchasePaid extends IBase {
|
|
100
|
+
event: 'purchase_paid';
|
|
101
|
+
ecommerce: IEcommercePurchase | null;
|
|
102
|
+
user_data: IUserData | null;
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
export interface IPixels {
|
|
100
106
|
fb_pixel_id?: number | string;
|
|
101
107
|
tiktok_pixel_id?: number | string;
|