@segment/analytics-browser-actions-tiktok-pixel 1.34.0 → 1.35.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/dist/cjs/common_fields.d.ts +2 -0
- package/dist/cjs/common_fields.js +156 -0
- package/dist/cjs/common_fields.js.map +1 -0
- package/dist/cjs/generated-types.d.ts +1 -0
- package/dist/cjs/index.js +89 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/init-script.d.ts +1 -1
- package/dist/cjs/init-script.js +4 -2
- package/dist/cjs/init-script.js.map +1 -1
- package/dist/cjs/reportWebEvent/formatter.d.ts +1 -0
- package/dist/cjs/reportWebEvent/formatter.js +12 -1
- package/dist/cjs/reportWebEvent/formatter.js.map +1 -1
- package/dist/cjs/reportWebEvent/generated-types.d.ts +9 -4
- package/dist/cjs/reportWebEvent/index.js +12 -122
- package/dist/cjs/reportWebEvent/index.js.map +1 -1
- package/dist/cjs/types.d.ts +12 -7
- package/dist/esm/common_fields.d.ts +2 -0
- package/dist/esm/common_fields.js +153 -0
- package/dist/esm/common_fields.js.map +1 -0
- package/dist/esm/generated-types.d.ts +1 -0
- package/dist/esm/index.js +89 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init-script.d.ts +1 -1
- package/dist/esm/init-script.js +4 -2
- package/dist/esm/init-script.js.map +1 -1
- package/dist/esm/reportWebEvent/formatter.d.ts +1 -0
- package/dist/esm/reportWebEvent/formatter.js +10 -0
- package/dist/esm/reportWebEvent/formatter.js.map +1 -1
- package/dist/esm/reportWebEvent/generated-types.d.ts +9 -4
- package/dist/esm/reportWebEvent/index.js +13 -123
- package/dist/esm/reportWebEvent/index.js.map +1 -1
- package/dist/esm/types.d.ts +12 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/common_fields.ts +158 -0
- package/src/generated-types.ts +5 -1
- package/src/index.ts +91 -7
- package/src/init-script.ts +4 -2
- package/src/reportWebEvent/__tests__/index.test.ts +128 -6
- package/src/reportWebEvent/formatter.ts +9 -0
- package/src/reportWebEvent/generated-types.ts +30 -10
- package/src/reportWebEvent/index.ts +15 -130
- package/src/types.ts +15 -7
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commonFields = void 0;
|
|
4
|
+
exports.commonFields = {
|
|
5
|
+
event: {
|
|
6
|
+
label: 'Event Name',
|
|
7
|
+
type: 'string',
|
|
8
|
+
required: true,
|
|
9
|
+
description: 'Conversion event name. Please refer to the "Supported Web Events" section on in TikTok’s [Pixel SDK documentation](https://business-api.tiktok.com/portal/docs?id=1739585696931842) for accepted event names.'
|
|
10
|
+
},
|
|
11
|
+
event_id: {
|
|
12
|
+
label: 'Event ID',
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Any hashed ID that can identify a unique user/session.',
|
|
15
|
+
default: {
|
|
16
|
+
'@path': '$.messageId'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
phone_number: {
|
|
20
|
+
label: 'Phone Number',
|
|
21
|
+
description: 'A single phone number in E.164 standard format. TikTok Pixel will hash this value before sending to TikTok. e.g. +14150000000. Segment will hash this value before sending to TikTok.',
|
|
22
|
+
type: 'string',
|
|
23
|
+
multiple: true,
|
|
24
|
+
default: {
|
|
25
|
+
'@if': {
|
|
26
|
+
exists: { '@path': '$.properties.phone' },
|
|
27
|
+
then: { '@path': '$.properties.phone' },
|
|
28
|
+
else: { '@path': '$.context.traits.phone' }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
email: {
|
|
33
|
+
label: 'Email',
|
|
34
|
+
description: 'A single email address. TikTok Pixel will be hash this value before sending to TikTok.',
|
|
35
|
+
type: 'string',
|
|
36
|
+
multiple: true,
|
|
37
|
+
default: {
|
|
38
|
+
'@if': {
|
|
39
|
+
exists: { '@path': '$.properties.email' },
|
|
40
|
+
then: { '@path': '$.properties.email' },
|
|
41
|
+
else: { '@path': '$.context.traits.email' }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
order_id: {
|
|
46
|
+
label: 'Order ID',
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'Order ID of the transaction.',
|
|
49
|
+
default: {
|
|
50
|
+
'@path': '$.properties.order_id'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
shop_id: {
|
|
54
|
+
label: 'Shop ID',
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'Shop ID of the transaction.',
|
|
57
|
+
default: {
|
|
58
|
+
'@path': '$.properties.shop_id'
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
external_id: {
|
|
62
|
+
label: 'External ID',
|
|
63
|
+
description: 'Uniquely identifies the user who triggered the conversion event. TikTok Pixel will hash this value before sending to TikTok.',
|
|
64
|
+
type: 'string',
|
|
65
|
+
multiple: true,
|
|
66
|
+
default: {
|
|
67
|
+
'@if': {
|
|
68
|
+
exists: { '@path': '$.userId' },
|
|
69
|
+
then: { '@path': '$.userId' },
|
|
70
|
+
else: { '@path': '$.anonymousId' }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
contents: {
|
|
75
|
+
label: 'Contents',
|
|
76
|
+
type: 'object',
|
|
77
|
+
multiple: true,
|
|
78
|
+
description: 'Related item details for the event.',
|
|
79
|
+
properties: {
|
|
80
|
+
price: {
|
|
81
|
+
label: 'Price',
|
|
82
|
+
description: 'Price of the item.',
|
|
83
|
+
type: 'number'
|
|
84
|
+
},
|
|
85
|
+
quantity: {
|
|
86
|
+
label: 'Quantity',
|
|
87
|
+
description: 'Number of items.',
|
|
88
|
+
type: 'number'
|
|
89
|
+
},
|
|
90
|
+
content_category: {
|
|
91
|
+
label: 'Content Category',
|
|
92
|
+
description: 'Category of the product item.',
|
|
93
|
+
type: 'string'
|
|
94
|
+
},
|
|
95
|
+
content_id: {
|
|
96
|
+
label: 'Content ID',
|
|
97
|
+
description: 'ID of the product item.',
|
|
98
|
+
type: 'string'
|
|
99
|
+
},
|
|
100
|
+
content_name: {
|
|
101
|
+
label: 'Content Name',
|
|
102
|
+
description: 'Name of the product item.',
|
|
103
|
+
type: 'string'
|
|
104
|
+
},
|
|
105
|
+
brand: {
|
|
106
|
+
label: 'Brand',
|
|
107
|
+
description: 'Brand name of the product item.',
|
|
108
|
+
type: 'string'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
content_type: {
|
|
113
|
+
label: 'Content Type',
|
|
114
|
+
description: 'Type of the product item. When the `content_id` in the `Contents` field is specified as a `sku_id`, set this field to `product`. When the `content_id` in the `Contents` field is specified as an `item_group_id`, set this field to `product_group`.',
|
|
115
|
+
type: 'string',
|
|
116
|
+
choices: [
|
|
117
|
+
{ label: 'product', value: 'product' },
|
|
118
|
+
{ label: 'product_group', value: 'product_group' }
|
|
119
|
+
],
|
|
120
|
+
default: 'product'
|
|
121
|
+
},
|
|
122
|
+
currency: {
|
|
123
|
+
label: 'Currency',
|
|
124
|
+
type: 'string',
|
|
125
|
+
description: 'Currency for the value specified as ISO 4217 code.',
|
|
126
|
+
default: {
|
|
127
|
+
'@path': '$.properties.currency'
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
value: {
|
|
131
|
+
label: 'Value',
|
|
132
|
+
type: 'number',
|
|
133
|
+
description: 'Value of the order or items sold.',
|
|
134
|
+
default: {
|
|
135
|
+
'@if': {
|
|
136
|
+
exists: { '@path': '$.properties.value' },
|
|
137
|
+
then: { '@path': '$.properties.value' },
|
|
138
|
+
else: { '@path': '$.properties.revenue' }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
description: {
|
|
143
|
+
label: 'Description',
|
|
144
|
+
type: 'string',
|
|
145
|
+
description: 'A string description of the web event.'
|
|
146
|
+
},
|
|
147
|
+
query: {
|
|
148
|
+
label: 'Query',
|
|
149
|
+
type: 'string',
|
|
150
|
+
description: 'The text string that was searched for.',
|
|
151
|
+
default: {
|
|
152
|
+
'@path': '$.properties.query'
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=common_fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common_fields.js","sourceRoot":"","sources":["../../src/common_fields.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAA+B;IACtD,KAAK,EAAE;QACL,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,WAAW,EACT,+MAA+M;KAClN;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,wDAAwD;QACrE,OAAO,EAAE;YACP,OAAO,EAAE,aAAa;SACvB;KACF;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,uLAAuL;QACzL,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACzC,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACvC,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;aAC5C;SACF;KACF;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,wFAAwF;QACrG,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACzC,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACvC,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;aAC5C;SACF;KACF;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,UA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,KAAK,EAAE,OAAO;gBACd,WAAW,EAAE,iCAAiC;gBAC9C,IAAI,EAAE,QAAQ;aACf;SACF;KACF;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,uPAAuP;QACzP,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;YACtC,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,EAAE;SACnD;QACD,OAAO,EAAE,SAAS;KACnB;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oDAAoD;QACjE,OAAO,EAAE;YACP,OAAO,EAAE,uBAAuB;SACjC;KACF;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACzC,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACvC,IAAI,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE;aAC1C;SACF;KACF;IACD,WAAW,EAAE;QACX,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,wCAAwC;KACtD;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,wCAAwC;QACrD,OAAO,EAAE;YACP,OAAO,EAAE,oBAAoB;SAC9B;KACF;CACF,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -13,11 +13,17 @@ const productProperties = {
|
|
|
13
13
|
quantity: {
|
|
14
14
|
'@path': '$.quantity'
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
content_category: {
|
|
17
17
|
'@path': '$.category'
|
|
18
18
|
},
|
|
19
19
|
content_id: {
|
|
20
20
|
'@path': '$.product_id'
|
|
21
|
+
},
|
|
22
|
+
content_name: {
|
|
23
|
+
'@path': '$.name'
|
|
24
|
+
},
|
|
25
|
+
brand: {
|
|
26
|
+
'@path': '$.brand'
|
|
21
27
|
}
|
|
22
28
|
};
|
|
23
29
|
const singleProductContents = {
|
|
@@ -47,9 +53,49 @@ exports.destination = {
|
|
|
47
53
|
slug: 'actions-tiktok-pixel',
|
|
48
54
|
mode: 'device',
|
|
49
55
|
presets: [
|
|
56
|
+
{
|
|
57
|
+
name: 'Complete Payment',
|
|
58
|
+
subscribe: 'event = "Order Completed"',
|
|
59
|
+
partnerAction: 'reportWebEvent',
|
|
60
|
+
mapping: {
|
|
61
|
+
...multiProductContents,
|
|
62
|
+
event: 'CompletePayment'
|
|
63
|
+
},
|
|
64
|
+
type: 'automatic'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'Contact',
|
|
68
|
+
subscribe: 'event = "Callback Started"',
|
|
69
|
+
partnerAction: 'reportWebEvent',
|
|
70
|
+
mapping: {
|
|
71
|
+
...actions_core_1.defaultValues(reportWebEvent_1.default.fields),
|
|
72
|
+
event: 'Contact'
|
|
73
|
+
},
|
|
74
|
+
type: 'automatic'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Subscribe',
|
|
78
|
+
subscribe: 'event = "Subscription Created"',
|
|
79
|
+
partnerAction: 'reportWebEvent',
|
|
80
|
+
mapping: {
|
|
81
|
+
...actions_core_1.defaultValues(reportWebEvent_1.default.fields),
|
|
82
|
+
event: 'Subscribe'
|
|
83
|
+
},
|
|
84
|
+
type: 'automatic'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'Submit Form',
|
|
88
|
+
subscribe: 'event = "Form Submitted"',
|
|
89
|
+
partnerAction: 'reportWebEvent',
|
|
90
|
+
mapping: {
|
|
91
|
+
...actions_core_1.defaultValues(reportWebEvent_1.default.fields),
|
|
92
|
+
event: 'SubmitForm'
|
|
93
|
+
},
|
|
94
|
+
type: 'automatic'
|
|
95
|
+
},
|
|
50
96
|
{
|
|
51
97
|
name: 'View Content',
|
|
52
|
-
subscribe: '
|
|
98
|
+
subscribe: 'event = "Product Viewed"',
|
|
53
99
|
partnerAction: 'reportWebEvent',
|
|
54
100
|
mapping: {
|
|
55
101
|
...singleProductContents,
|
|
@@ -57,6 +103,16 @@ exports.destination = {
|
|
|
57
103
|
},
|
|
58
104
|
type: 'automatic'
|
|
59
105
|
},
|
|
106
|
+
{
|
|
107
|
+
name: 'Click Button',
|
|
108
|
+
subscribe: 'event = "Product Clicked"',
|
|
109
|
+
partnerAction: 'reportWebEvent',
|
|
110
|
+
mapping: {
|
|
111
|
+
...singleProductContents,
|
|
112
|
+
event: 'ClickButton'
|
|
113
|
+
},
|
|
114
|
+
type: 'automatic'
|
|
115
|
+
},
|
|
60
116
|
{
|
|
61
117
|
name: 'Search',
|
|
62
118
|
subscribe: 'event = "Products Searched"',
|
|
@@ -109,13 +165,33 @@ exports.destination = {
|
|
|
109
165
|
},
|
|
110
166
|
{
|
|
111
167
|
name: 'Place an Order',
|
|
112
|
-
subscribe: 'event = "Order
|
|
168
|
+
subscribe: 'event = "Order Placed"',
|
|
113
169
|
partnerAction: 'reportWebEvent',
|
|
114
170
|
mapping: {
|
|
115
171
|
...multiProductContents,
|
|
116
172
|
event: 'PlaceAnOrder'
|
|
117
173
|
},
|
|
118
174
|
type: 'automatic'
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'Download',
|
|
178
|
+
subscribe: 'event = "Download Link Clicked"',
|
|
179
|
+
partnerAction: 'reportWebEvent',
|
|
180
|
+
mapping: {
|
|
181
|
+
...actions_core_1.defaultValues(reportWebEvent_1.default.fields),
|
|
182
|
+
event: 'Download'
|
|
183
|
+
},
|
|
184
|
+
type: 'automatic'
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'Complete Registration',
|
|
188
|
+
subscribe: 'event = "Signed Up"',
|
|
189
|
+
partnerAction: 'reportWebEvent',
|
|
190
|
+
mapping: {
|
|
191
|
+
...actions_core_1.defaultValues(reportWebEvent_1.default.fields),
|
|
192
|
+
event: 'CompleteRegistration'
|
|
193
|
+
},
|
|
194
|
+
type: 'automatic'
|
|
119
195
|
}
|
|
120
196
|
],
|
|
121
197
|
settings: {
|
|
@@ -125,15 +201,22 @@ exports.destination = {
|
|
|
125
201
|
description: "Your TikTok Pixel ID. Please see TikTok's [Pixel documentation](https://ads.tiktok.com/marketing_api/docs?id=1739583652957185) for information on how to find this value.",
|
|
126
202
|
required: true
|
|
127
203
|
},
|
|
204
|
+
ldu: {
|
|
205
|
+
label: 'Limited Data Use',
|
|
206
|
+
type: 'boolean',
|
|
207
|
+
description: 'In order to help facilitate advertiser\'s compliance with the right to opt-out of sale and sharing of personal data under certain U.S. state privacy laws, TikTok offers a Limited Data Use ("LDU") feature. For more information, please refer to TikTok\'s [documentation page](https://business-api.tiktok.com/portal/docs?id=1770092377990145).'
|
|
208
|
+
},
|
|
128
209
|
useExistingPixel: {
|
|
129
|
-
label: 'Use Existing Pixel',
|
|
210
|
+
label: '[Deprecated] Use Existing Pixel',
|
|
130
211
|
type: 'boolean',
|
|
131
|
-
|
|
212
|
+
default: false,
|
|
213
|
+
required: false,
|
|
214
|
+
description: 'Deprecated. Please do not provide any value.'
|
|
132
215
|
}
|
|
133
216
|
},
|
|
134
217
|
initialize: async ({ settings }, deps) => {
|
|
135
218
|
if (!settings.useExistingPixel) {
|
|
136
|
-
init_script_1.initScript(settings
|
|
219
|
+
init_script_1.initScript(settings);
|
|
137
220
|
}
|
|
138
221
|
await deps.resolveWhen(() => window.ttq != null, 100);
|
|
139
222
|
return window.ttq;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAEA,oEAA8E;AAC9E,8EAA6C;AAC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BAAa,CAAC,wBAAc,CAAC,MAAM,CAAC;gBACvC,KAAK,EAAE,sBAAsB;aAC9B;YACD,IAAI,EAAE,WAAW;SAClB;KACF;IACD,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,2KAA2K;YAC7K,QAAQ,EAAE,IAAI;SACf;QACD,GAAG,EAAE;YACH,KAAK,EAAE,kBAAkB;YACzB,IAAI,EAAE,SAAS;YACf,WAAW,EACT,qVAAqV;SACxV;QACD,gBAAgB,EAAE;YAEhB,KAAK,EAAE,iCAAiC;YACxC,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,8CAA8C;SAC5D;KACF;IACD,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE;QACvC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE;YAC9B,wBAAU,CAAC,QAAQ,CAAC,CAAA;SACrB;QACD,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,GAAG,CAAC,CAAA;QACrD,OAAO,MAAM,CAAC,GAAG,CAAA;IACnB,CAAC;IACD,OAAO,EAAE;QACP,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,yBAAkB,CAAC,mBAAW,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function initScript(
|
|
1
|
+
export declare function initScript(settings: any): void;
|
package/dist/cjs/init-script.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initScript = void 0;
|
|
4
|
-
function initScript(
|
|
4
|
+
function initScript(settings) {
|
|
5
5
|
!(function (w, d, t) {
|
|
6
6
|
w.TiktokAnalyticsObject = t;
|
|
7
7
|
var ttq = (w[t] = w[t] || []);
|
|
@@ -46,7 +46,9 @@ function initScript(pixelCode) {
|
|
|
46
46
|
var a = document.getElementsByTagName('script')[0];
|
|
47
47
|
a.parentNode.insertBefore(o, a);
|
|
48
48
|
});
|
|
49
|
-
ttq.load(pixelCode
|
|
49
|
+
ttq.load(settings.pixelCode, {
|
|
50
|
+
limited_data_use: settings.ldu ? settings.ldu : false
|
|
51
|
+
});
|
|
50
52
|
ttq.page();
|
|
51
53
|
})(window, document, 'ttq');
|
|
52
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-script.js","sourceRoot":"","sources":["../../src/init-script.ts"],"names":[],"mappings":";;;AAEA,SAAgB,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"init-script.js","sourceRoot":"","sources":["../../src/init-script.ts"],"names":[],"mappings":";;;AAEA,SAAgB,UAAU,CAAC,QAAQ;IACjC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;QACjB,CAAC,CAAC,qBAAqB,GAAG,CAAC,CAAA;QAC3B,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAC5B;QAAA,CAAC,GAAG,CAAC,OAAO,GAAG;YACd,MAAM;YACN,OAAO;YACP,UAAU;YACV,WAAW;YACX,OAAO;YACP,IAAI;YACJ,KAAK;YACL,MAAM;YACN,OAAO;YACP,OAAO;YACP,OAAO;YACP,cAAc;YACd,eAAe;SAChB,CAAC;YACA,CAAC,GAAG,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,CAAC;gBAC/B,CAAC,CAAC,CAAC,CAAC,GAAG;oBACL,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;g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AAI,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CACvC;gBAAA,CAAC,CAAC,CAAC,IAAI,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,CAAA;gBACxF,IAAI,CAAC,GAAG,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;gBAClD,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACjC,CAAC,CAAC,CAAA;QAEJ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;YAC3B,gBAAgB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK;SACtD,CAAC,CAAA;QACF,GAAG,CAAC,IAAI,EAAE,CAAA;IACZ,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;AAC7B,CAAC;AAjDD,gCAiDC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatPhone = void 0;
|
|
3
|
+
exports.handleArrayInput = exports.formatPhone = void 0;
|
|
4
4
|
function formatPhone(phone) {
|
|
5
5
|
if (!phone)
|
|
6
6
|
return undefined;
|
|
@@ -13,4 +13,15 @@ function formatPhone(phone) {
|
|
|
13
13
|
return formattedPhone;
|
|
14
14
|
}
|
|
15
15
|
exports.formatPhone = formatPhone;
|
|
16
|
+
function handleArrayInput(mightBeArray) {
|
|
17
|
+
if (typeof mightBeArray === 'string')
|
|
18
|
+
return mightBeArray;
|
|
19
|
+
if (typeof mightBeArray === 'undefined')
|
|
20
|
+
return '';
|
|
21
|
+
if (Array.isArray(mightBeArray)) {
|
|
22
|
+
return mightBeArray.length > 0 ? mightBeArray[0] : '';
|
|
23
|
+
}
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
exports.handleArrayInput = handleArrayInput;
|
|
16
27
|
//# sourceMappingURL=formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../src/reportWebEvent/formatter.ts"],"names":[],"mappings":";;;AAKA,SAAgB,WAAW,CAAC,KAAyB;IACnD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAE5B,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IAClD,IAAI,cAAc,KAAK,IAAI,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qCAAqC,CAAC,CAAA;KAC/D;IAED,IAAI,cAAc,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAA;IAEvD,cAAc,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAChD,OAAO,cAAc,CAAA;AACvB,CAAC;AAZD,kCAYC"}
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../src/reportWebEvent/formatter.ts"],"names":[],"mappings":";;;AAKA,SAAgB,WAAW,CAAC,KAAyB;IACnD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAE5B,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IAClD,IAAI,cAAc,KAAK,IAAI,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qCAAqC,CAAC,CAAA;KAC/D;IAED,IAAI,cAAc,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAA;IAEvD,cAAc,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAChD,OAAO,cAAc,CAAA;AACvB,CAAC;AAZD,kCAYC;AAED,SAAgB,gBAAgB,CAAC,YAA2C;IAC1E,IAAG,OAAO,YAAY,KAAK,QAAQ;QAAE,OAAO,YAAY,CAAA;IACxD,IAAG,OAAO,YAAY,KAAK,WAAW;QAAE,OAAO,EAAE,CAAA;IACjD,IAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAC;QAC7B,OAAO,YAAY,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,EAAE,CAAA;KACnD;IACD,OAAO,EAAE,CAAA;AACX,CAAC;AAPD,4CAOC"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
export interface Payload {
|
|
2
2
|
event: string;
|
|
3
3
|
event_id?: string;
|
|
4
|
-
phone_number?: string;
|
|
5
|
-
email?: string;
|
|
6
|
-
|
|
4
|
+
phone_number?: string[];
|
|
5
|
+
email?: string[];
|
|
6
|
+
order_id?: string;
|
|
7
|
+
shop_id?: string;
|
|
8
|
+
external_id?: string[];
|
|
7
9
|
contents?: {
|
|
8
10
|
price?: number;
|
|
9
11
|
quantity?: number;
|
|
10
|
-
|
|
12
|
+
content_category?: string;
|
|
11
13
|
content_id?: string;
|
|
14
|
+
content_name?: string;
|
|
15
|
+
brand?: string;
|
|
12
16
|
}[];
|
|
17
|
+
content_type?: string;
|
|
13
18
|
currency?: string;
|
|
14
19
|
value?: number;
|
|
15
20
|
description?: string;
|
|
@@ -1,144 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const formatter_1 = require("./formatter");
|
|
4
|
+
const common_fields_1 = require("../common_fields");
|
|
4
5
|
const action = {
|
|
5
6
|
title: 'Report Web Event',
|
|
6
7
|
description: 'Report events directly to TikTok. Data shared can power TikTok solutions like dynamic product ads, custom targeting, campaign optimization and attribution.',
|
|
7
8
|
platform: 'web',
|
|
8
9
|
defaultSubscription: 'type = "track"',
|
|
9
10
|
fields: {
|
|
10
|
-
|
|
11
|
-
label: 'Event Name',
|
|
12
|
-
type: 'string',
|
|
13
|
-
required: true,
|
|
14
|
-
description: 'Conversion event name. Please refer to the "Supported Web Events" section on in TikTok’s [Pixel documentation](https://ads.tiktok.com/marketing_api/docs?id=1739585696931842) for accepted event names.'
|
|
15
|
-
},
|
|
16
|
-
event_id: {
|
|
17
|
-
label: 'Event ID',
|
|
18
|
-
type: 'string',
|
|
19
|
-
description: 'Any hashed ID that can identify a unique user/session.',
|
|
20
|
-
default: {
|
|
21
|
-
'@path': '$.messageId'
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
phone_number: {
|
|
25
|
-
label: 'Phone Number',
|
|
26
|
-
description: 'Phone number of the user who triggered the conversion event, in E.164 standard format, e.g. +14150000000. Segment will hash this value before sending to TikTok.',
|
|
27
|
-
type: 'string',
|
|
28
|
-
default: {
|
|
29
|
-
'@if': {
|
|
30
|
-
exists: { '@path': '$.properties.phone' },
|
|
31
|
-
then: { '@path': '$.properties.phone' },
|
|
32
|
-
else: { '@path': '$.traits.phone' }
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
email: {
|
|
37
|
-
label: 'Email',
|
|
38
|
-
description: 'Email address of the user who triggered the conversion event. Segment will hash this value before sending to TikTok.',
|
|
39
|
-
type: 'string',
|
|
40
|
-
format: 'email',
|
|
41
|
-
default: {
|
|
42
|
-
'@if': {
|
|
43
|
-
exists: { '@path': '$.properties.email' },
|
|
44
|
-
then: { '@path': '$.properties.email' },
|
|
45
|
-
else: { '@path': '$.traits.email' }
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
external_id: {
|
|
50
|
-
label: 'External ID',
|
|
51
|
-
description: 'Uniquely identifies the user who triggered the conversion event. Segment will hash this value before sending to TikTok.',
|
|
52
|
-
type: 'string',
|
|
53
|
-
default: {
|
|
54
|
-
'@if': {
|
|
55
|
-
exists: { '@path': '$.userId' },
|
|
56
|
-
then: { '@path': '$.userId' },
|
|
57
|
-
else: { '@path': '$.anonymousId' }
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
contents: {
|
|
62
|
-
label: 'Contents',
|
|
63
|
-
type: 'object',
|
|
64
|
-
multiple: true,
|
|
65
|
-
description: 'Related items in a web event.',
|
|
66
|
-
properties: {
|
|
67
|
-
price: {
|
|
68
|
-
label: 'Price',
|
|
69
|
-
description: 'Price of the item.',
|
|
70
|
-
type: 'number'
|
|
71
|
-
},
|
|
72
|
-
quantity: {
|
|
73
|
-
label: 'Quantity',
|
|
74
|
-
description: 'Number of items.',
|
|
75
|
-
type: 'number'
|
|
76
|
-
},
|
|
77
|
-
content_type: {
|
|
78
|
-
label: 'Content Type',
|
|
79
|
-
description: 'Type of the product item.',
|
|
80
|
-
type: 'string'
|
|
81
|
-
},
|
|
82
|
-
content_id: {
|
|
83
|
-
label: 'Content ID',
|
|
84
|
-
description: 'ID of the product item.',
|
|
85
|
-
type: 'string'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
currency: {
|
|
90
|
-
label: 'Currency',
|
|
91
|
-
type: 'string',
|
|
92
|
-
description: 'Currency for the value specified as ISO 4217 code.',
|
|
93
|
-
default: {
|
|
94
|
-
'@path': '$.properties.currency'
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
value: {
|
|
98
|
-
label: 'Value',
|
|
99
|
-
type: 'number',
|
|
100
|
-
description: 'Value of the order or items sold.',
|
|
101
|
-
default: {
|
|
102
|
-
'@if': {
|
|
103
|
-
exists: { '@path': '$.properties.value' },
|
|
104
|
-
then: { '@path': '$.properties.value' },
|
|
105
|
-
else: { '@path': '$.properties.revenue' }
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
description: {
|
|
110
|
-
label: 'Description',
|
|
111
|
-
type: 'string',
|
|
112
|
-
description: 'A string description of the web event.',
|
|
113
|
-
default: {
|
|
114
|
-
'@path': '$.properties.description'
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
query: {
|
|
118
|
-
label: 'Query',
|
|
119
|
-
type: 'string',
|
|
120
|
-
description: 'The text string that was searched for.',
|
|
121
|
-
default: {
|
|
122
|
-
'@path': '$.properties.query'
|
|
123
|
-
}
|
|
124
|
-
}
|
|
11
|
+
...common_fields_1.commonFields
|
|
125
12
|
},
|
|
126
13
|
perform: (ttq, { payload }) => {
|
|
127
|
-
if (payload.email || payload.phone_number) {
|
|
14
|
+
if (payload.email || payload.phone_number || payload.external_id) {
|
|
128
15
|
ttq.identify({
|
|
129
|
-
email: payload.email,
|
|
130
|
-
phone_number: formatter_1.formatPhone(payload.phone_number),
|
|
131
|
-
external_id: payload.external_id
|
|
16
|
+
email: formatter_1.handleArrayInput(payload.email),
|
|
17
|
+
phone_number: formatter_1.formatPhone(formatter_1.handleArrayInput(payload.phone_number)),
|
|
18
|
+
external_id: formatter_1.handleArrayInput(payload.external_id)
|
|
132
19
|
});
|
|
133
20
|
}
|
|
134
21
|
ttq.track(payload.event, {
|
|
135
22
|
contents: payload.contents ? payload.contents : [],
|
|
23
|
+
content_type: payload.content_type ? payload.content_type : undefined,
|
|
136
24
|
currency: payload.currency ? payload.currency : 'USD',
|
|
137
25
|
value: payload.value ? payload.value : 0,
|
|
138
|
-
|
|
139
|
-
|
|
26
|
+
query: payload.query ? payload.query : undefined,
|
|
27
|
+
description: payload.description ? payload.description : undefined,
|
|
28
|
+
order_id: payload.order_id ? payload.order_id : undefined,
|
|
29
|
+
shop_id: payload.shop_id ? payload.shop_id : undefined
|
|
140
30
|
}, {
|
|
141
|
-
event_id: payload.event_id
|
|
31
|
+
event_id: payload.event_id ? payload.event_id : ''
|
|
142
32
|
});
|
|
143
33
|
}
|
|
144
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reportWebEvent/index.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reportWebEvent/index.ts"],"names":[],"mappings":";;AAGA,2CAA2D;AAE3D,oDAA+C;AAE/C,MAAM,MAAM,GAA4D;IACtE,KAAK,EAAE,kBAAkB;IACzB,WAAW,EACT,6JAA6J;IAC/J,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,GAAG,4BAAY;KAChB;IACD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC5B,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,WAAW,EAAE;YAChE,GAAG,CAAC,QAAQ,CAAC;gBACX,KAAK,EAAE,4BAAgB,CAAC,OAAO,CAAC,KAAK,CAAC;gBACtC,YAAY,EAAE,uBAAW,CAAC,4BAAgB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBACjE,WAAW,EAAE,4BAAgB,CAAC,OAAO,CAAC,WAAW,CAAC;aACnD,CAAC,CAAA;SACH;QAED,GAAG,CAAC,KAAK,CACP,OAAO,CAAC,KAAK,EACb;YACE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;YAClD,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;YACrE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;YACrD,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACxC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YAChD,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;YAClE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YACzD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;SACvD,EACD;YACE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;SACnD,CACF,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -5,17 +5,22 @@ export interface TikTokPixel {
|
|
|
5
5
|
phone_number: string | undefined;
|
|
6
6
|
external_id: string | undefined;
|
|
7
7
|
}) => void;
|
|
8
|
-
track: (event: string, { contents, currency, value, description, query }: {
|
|
8
|
+
track: (event: string, { contents, content_type, currency, value, description, query, order_id, shop_id }: {
|
|
9
9
|
contents: {
|
|
10
|
-
price?: number;
|
|
11
|
-
quantity?: number;
|
|
12
|
-
|
|
13
|
-
content_id?: string;
|
|
10
|
+
price?: number | undefined;
|
|
11
|
+
quantity?: number | undefined;
|
|
12
|
+
content_category?: string | undefined;
|
|
13
|
+
content_id?: string | undefined;
|
|
14
|
+
content_name?: string | undefined;
|
|
15
|
+
brand?: string | undefined;
|
|
14
16
|
}[] | [];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
content_type: string | undefined;
|
|
18
|
+
currency: string | undefined;
|
|
19
|
+
value: number | undefined;
|
|
17
20
|
description: string | undefined;
|
|
18
21
|
query: string | undefined;
|
|
22
|
+
order_id: string | undefined;
|
|
23
|
+
shop_id: string | undefined;
|
|
19
24
|
}, { event_id }: {
|
|
20
25
|
event_id: string | undefined;
|
|
21
26
|
}) => void;
|