@walkeros/web-destination-tiktok 3.3.0-next-1776098542393
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/LICENSE +21 -0
- package/README.md +280 -0
- package/dist/dev.d.mts +266 -0
- package/dist/dev.d.ts +266 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/examples/index.d.mts +233 -0
- package/dist/examples/index.d.ts +233 -0
- package/dist/examples/index.js +14498 -0
- package/dist/examples/index.mjs +14476 -0
- package/dist/index.browser.js +1 -0
- package/dist/index.d.mts +142 -0
- package/dist/index.d.ts +142 -0
- package/dist/index.es5.js +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/dist/walkerOS.json +925 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 elbWalker GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
<p align="left">
|
|
2
|
+
<a href="https://www.walkeros.io">
|
|
3
|
+
<img alt="walkerOS" title="walkerOS" src="https://www.walkeros.io/img/walkerOS_logo.svg" width="256px"/>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# TikTok Pixel Destination for walkerOS
|
|
8
|
+
|
|
9
|
+
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/web/destinations/tiktok)
|
|
10
|
+
•
|
|
11
|
+
[NPM Package](https://www.npmjs.com/package/@walkeros/web-destination-tiktok)
|
|
12
|
+
• [Documentation](https://www.walkeros.io/docs/destinations/web/tiktok)
|
|
13
|
+
|
|
14
|
+
This package forwards walkerOS events to the
|
|
15
|
+
[TikTok Pixel](https://business-api.tiktok.com/portal/docs?id=1739585702922241)
|
|
16
|
+
— conversion tracking and audience building for TikTok Ads. The destination
|
|
17
|
+
wraps the standard TikTok Pixel snippet (loaded from
|
|
18
|
+
`https://analytics.tiktok.com/i18n/pixel/events.js`); there is no npm SDK for
|
|
19
|
+
the browser pixel.
|
|
20
|
+
|
|
21
|
+
walkerOS follows a **source → collector → destination** architecture. This
|
|
22
|
+
TikTok destination receives processed events from the walkerOS collector and
|
|
23
|
+
forwards them as `ttq.track`, `ttq.identify`, and consent toggles via
|
|
24
|
+
`ttq.enableCookie` / `ttq.disableCookie`.
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **Default event forwarding** — every walkerOS event becomes
|
|
29
|
+
`ttq.track(name, params, { event_id })`. The `event_id` is the walkerOS event
|
|
30
|
+
id, ready for deduplication with a server-side Events API destination.
|
|
31
|
+
- **Standard event renaming** — `mapping.name` flips walkerOS event names
|
|
32
|
+
(`"product view"`) into TikTok's rigid 14-event taxonomy (`"ViewContent"`). An
|
|
33
|
+
exported `StandardEventNames` TypeScript union lights up IDE autocomplete;
|
|
34
|
+
arbitrary strings are still allowed for custom events.
|
|
35
|
+
- **Advanced Matching** — destination-level + per-event `settings.identify`
|
|
36
|
+
resolving to `{ email, phone_number, external_id }`. Runtime state diffing
|
|
37
|
+
skips redundant `ttq.identify()` calls on unchanged values. The TikTok SDK
|
|
38
|
+
auto-hashes all values with SHA256 before sending.
|
|
39
|
+
- **Custom event properties** — `settings.include` flattens walkerOS event
|
|
40
|
+
sections (`data`, `globals`, `user`, …) with prefixes (`data_id`, `user_id`,
|
|
41
|
+
…) onto the params object. Useful for custom events where TikTok won't
|
|
42
|
+
optimize anyway.
|
|
43
|
+
- **Consent cookie toggling** — the `on('consent')` handler reads
|
|
44
|
+
`config.consent` and calls `ttq.enableCookie()` when all required consent keys
|
|
45
|
+
are granted, `ttq.disableCookie()` otherwise.
|
|
46
|
+
- **No npm dependency** — TikTok ships only the script-tag snippet. The
|
|
47
|
+
destination injects the CDN tag via `addScript()` exactly like the Meta Pixel
|
|
48
|
+
destination.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
npm install @walkeros/web-destination-tiktok
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { startFlow } from '@walkeros/collector';
|
|
60
|
+
import { destinationTikTok } from '@walkeros/web-destination-tiktok';
|
|
61
|
+
|
|
62
|
+
await startFlow({
|
|
63
|
+
consent: { marketing: false },
|
|
64
|
+
destinations: {
|
|
65
|
+
tiktok: {
|
|
66
|
+
code: destinationTikTok,
|
|
67
|
+
config: {
|
|
68
|
+
consent: { marketing: true },
|
|
69
|
+
settings: {
|
|
70
|
+
apiKey: 'C4XXXXXXXXXXXXXXXXXXX', // your TikTok Pixel ID
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Configuration
|
|
79
|
+
|
|
80
|
+
### Settings (destination-level)
|
|
81
|
+
|
|
82
|
+
| Name | Type | Description | Required |
|
|
83
|
+
| ------------------ | --------------- | ----------------------------------------------------------------------------------------------------- | -------- |
|
|
84
|
+
| `apiKey` | `string` | TikTok Pixel ID — first argument to `ttq.load(...)` | Yes |
|
|
85
|
+
| `identify` | `Mapping.Value` | Resolves to an Advanced Matching object (`email`, `phone_number`, `external_id`). SHA256 auto-hashed. | No |
|
|
86
|
+
| `include` | `string[]` | walkerOS event sections to flatten with prefix (`data` → `data_*`, `globals` → `globals_*`, …) | No |
|
|
87
|
+
| `auto_config` | `boolean` | TikTok default `true`. Enable automatic form field detection for Advanced Matching | No |
|
|
88
|
+
| `limited_data_use` | `boolean` | TikTok default `false`. Restrict data use under U.S. state privacy laws | No |
|
|
89
|
+
|
|
90
|
+
Any additional snake_case TikTok Pixel init option (passthrough) is forwarded to
|
|
91
|
+
`ttq.load(apiKey, options)` unchanged.
|
|
92
|
+
|
|
93
|
+
### Mapping (`rule.settings`)
|
|
94
|
+
|
|
95
|
+
| Name | Type | Description |
|
|
96
|
+
| ---------- | --------------- | ------------------------------------------------------------------------ |
|
|
97
|
+
| `identify` | `Mapping.Value` | Per-event Advanced Matching override. Same shape as `settings.identify`. |
|
|
98
|
+
| `include` | `string[]` | Replaces destination-level `include` for this rule. |
|
|
99
|
+
|
|
100
|
+
`mapping.name` (the walkerOS-standard event-rename mechanism) flips the walkerOS
|
|
101
|
+
event name into TikTok's standard event taxonomy.
|
|
102
|
+
|
|
103
|
+
## Standard Events
|
|
104
|
+
|
|
105
|
+
TikTok recognizes 14 standard events for ad optimization. Use `mapping.name` to
|
|
106
|
+
flip walkerOS event names into the rigid taxonomy:
|
|
107
|
+
|
|
108
|
+
| TikTok name | When to use |
|
|
109
|
+
| ---------------------- | ---------------------------------------------- |
|
|
110
|
+
| `ViewContent` | Product / content detail view |
|
|
111
|
+
| `ClickButton` | Generic CTA click |
|
|
112
|
+
| `Search` | Site search |
|
|
113
|
+
| `AddToWishlist` | Item added to a wishlist |
|
|
114
|
+
| `AddToCart` | Item added to cart |
|
|
115
|
+
| `InitiateCheckout` | User started checkout |
|
|
116
|
+
| `AddPaymentInfo` | Payment details entered |
|
|
117
|
+
| `CompletePayment` | Order successfully placed (primary conversion) |
|
|
118
|
+
| `PlaceAnOrder` | Order placed (alternative) |
|
|
119
|
+
| `Contact` | Lead / contact form |
|
|
120
|
+
| `Download` | Asset download |
|
|
121
|
+
| `SubmitForm` | Generic form submission |
|
|
122
|
+
| `CompleteRegistration` | User signup |
|
|
123
|
+
| `Subscribe` | Subscription start |
|
|
124
|
+
|
|
125
|
+
Custom event names (any string not in the list) are still tracked but receive no
|
|
126
|
+
optimization signal.
|
|
127
|
+
|
|
128
|
+
## Custom Event Properties
|
|
129
|
+
|
|
130
|
+
Two ways to attach custom params to a `ttq.track()` call:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// 1. Flatten walkerOS sections with settings.include
|
|
134
|
+
config: {
|
|
135
|
+
settings: {
|
|
136
|
+
apiKey: 'C4XXXXXXXXXXXXXXXXXXX',
|
|
137
|
+
include: ['data', 'user'], // → data_*, user_* params on every event
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 2. Explicit per-event params via mapping.data (the canonical pattern)
|
|
142
|
+
mapping: {
|
|
143
|
+
product: {
|
|
144
|
+
view: {
|
|
145
|
+
name: 'ViewContent',
|
|
146
|
+
data: {
|
|
147
|
+
map: {
|
|
148
|
+
content_type: { value: 'product' },
|
|
149
|
+
content_id: 'data.id',
|
|
150
|
+
content_name: 'data.name',
|
|
151
|
+
value: 'data.price',
|
|
152
|
+
currency: { key: 'data.currency', value: 'EUR' },
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
When a rule sets `mapping.data`, the resolved object is the params object —
|
|
161
|
+
`settings.include` is bypassed for that call. Set
|
|
162
|
+
`mapping.settings.include = []` to ensure no prefixed properties leak in.
|
|
163
|
+
|
|
164
|
+
## Advanced Matching
|
|
165
|
+
|
|
166
|
+
TikTok matches conversions back to TikTok users via three optional parameters:
|
|
167
|
+
`email`, `phone_number`, `external_id`. The SDK hashes them with SHA256 before
|
|
168
|
+
sending, so it's safe to pass raw values.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// Destination-level — fires on first push, then re-fires only when the
|
|
172
|
+
// resolved value changes (runtime state diffing)
|
|
173
|
+
config: {
|
|
174
|
+
settings: {
|
|
175
|
+
apiKey: 'C4XXXXXXXXXXXXXXXXXXX',
|
|
176
|
+
identify: {
|
|
177
|
+
map: {
|
|
178
|
+
email: 'user.email',
|
|
179
|
+
phone_number: 'user.phone',
|
|
180
|
+
external_id: 'user.id',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Per-event — overrides destination-level for one push (e.g. signup form)
|
|
187
|
+
mapping: {
|
|
188
|
+
user: {
|
|
189
|
+
register: {
|
|
190
|
+
name: 'CompleteRegistration',
|
|
191
|
+
settings: {
|
|
192
|
+
identify: {
|
|
193
|
+
map: {
|
|
194
|
+
email: 'data.email',
|
|
195
|
+
phone_number: 'data.phone',
|
|
196
|
+
external_id: 'data.user_id',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`ttq.identify()` always fires **before** `ttq.track()` so Advanced Matching is
|
|
206
|
+
set for the conversion event.
|
|
207
|
+
|
|
208
|
+
## Ecommerce — `CompletePayment`
|
|
209
|
+
|
|
210
|
+
The hero example. `mapping.data` builds the TikTok-native shape; `loop` walks
|
|
211
|
+
`event.nested` to produce the `contents` array; `{ key, value: 'EUR' }` provides
|
|
212
|
+
a fallback currency.
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
mapping: {
|
|
216
|
+
order: {
|
|
217
|
+
complete: {
|
|
218
|
+
name: 'CompletePayment',
|
|
219
|
+
data: {
|
|
220
|
+
map: {
|
|
221
|
+
content_type: { value: 'product' },
|
|
222
|
+
value: 'data.total',
|
|
223
|
+
currency: { key: 'data.currency', value: 'EUR' },
|
|
224
|
+
order_id: 'data.id',
|
|
225
|
+
contents: {
|
|
226
|
+
loop: [
|
|
227
|
+
'nested',
|
|
228
|
+
{
|
|
229
|
+
map: {
|
|
230
|
+
content_id: 'data.id',
|
|
231
|
+
content_name: 'data.name',
|
|
232
|
+
quantity: { key: 'data.quantity', value: 1 },
|
|
233
|
+
price: 'data.price',
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
settings: { include: [] },
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Consent
|
|
247
|
+
|
|
248
|
+
TikTok is an advertising platform — the typical walkerOS consent key is
|
|
249
|
+
`marketing` (whatever name your CMP reports). The walkerOS `config.consent` gate
|
|
250
|
+
blocks unconsented events from reaching the destination in the first place; the
|
|
251
|
+
destination's `on('consent')` handler then toggles TikTok's own cookie state for
|
|
252
|
+
attribution.
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
config: {
|
|
256
|
+
consent: { marketing: true },
|
|
257
|
+
settings: { apiKey: 'C4XXXXXXXXXXXXXXXXXXX' },
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
The handler iterates every key in `config.consent` and calls
|
|
262
|
+
`ttq.enableCookie()` only when **all** required keys are granted. Otherwise it
|
|
263
|
+
calls `ttq.disableCookie()`. This is the conservative semantic that matches
|
|
264
|
+
walkerOS's gating model.
|
|
265
|
+
|
|
266
|
+
> TikTok's SDK auto-fires `ttq.page()` once on load. The destination has no knob
|
|
267
|
+
> to suppress it — letting the auto page view fire is the expected behavior. If
|
|
268
|
+
> you need fine-grained page-view control, gate the destination behind a
|
|
269
|
+
> transformer.
|
|
270
|
+
|
|
271
|
+
## Contribute
|
|
272
|
+
|
|
273
|
+
Feel free to contribute by submitting an
|
|
274
|
+
[issue](https://github.com/elbwalker/walkerOS/issues), starting a
|
|
275
|
+
[discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
|
|
276
|
+
[contact](https://calendly.com/elb-alexander/30min).
|
|
277
|
+
|
|
278
|
+
## License
|
|
279
|
+
|
|
280
|
+
This project is licensed under the MIT License.
|
package/dist/dev.d.mts
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Mapping as Mapping$1, Flow } from '@walkeros/core';
|
|
4
|
+
import { DestinationWeb } from '@walkeros/web-core';
|
|
5
|
+
|
|
6
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
7
|
+
apiKey: z.ZodString;
|
|
8
|
+
auto_config: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
limited_data_use: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type Settings$1 = z.infer<typeof SettingsSchema>;
|
|
13
|
+
|
|
14
|
+
declare const MappingSchema: z.ZodObject<{
|
|
15
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
type Mapping = z.infer<typeof MappingSchema>;
|
|
18
|
+
|
|
19
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
20
|
+
declare const mapping: _walkeros_core_dev.JSONSchema;
|
|
21
|
+
|
|
22
|
+
type index$1_Mapping = Mapping;
|
|
23
|
+
declare const index$1_MappingSchema: typeof MappingSchema;
|
|
24
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
25
|
+
declare const index$1_mapping: typeof mapping;
|
|
26
|
+
declare const index$1_settings: typeof settings;
|
|
27
|
+
declare namespace index$1 {
|
|
28
|
+
export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Settings (destination-level).
|
|
33
|
+
*
|
|
34
|
+
* apiKey is the TikTok Pixel ID. `identify` resolves to Advanced Matching
|
|
35
|
+
* parameters (email, phone_number, external_id) — TikTok auto-hashes these
|
|
36
|
+
* before sending, so raw values are safe. `include` names walkerOS event
|
|
37
|
+
* sections to flatten into prefixed TikTok event parameters. All other
|
|
38
|
+
* TikTok-native snake_case options (e.g., `auto_config`, `limited_data_use`)
|
|
39
|
+
* are passed through to `ttq.load(apiKey, options)`.
|
|
40
|
+
*/
|
|
41
|
+
interface Settings {
|
|
42
|
+
/** TikTok Pixel ID — first argument to ttq.load(...). Required. */
|
|
43
|
+
apiKey: string;
|
|
44
|
+
/**
|
|
45
|
+
* walkerOS mapping value resolving to an Advanced Matching object with any
|
|
46
|
+
* of: `email`, `phone_number`, `external_id`. Applied on first push and
|
|
47
|
+
* re-fired only on change (runtime state in _state.lastIdentity).
|
|
48
|
+
*/
|
|
49
|
+
identify?: Mapping$1.Value;
|
|
50
|
+
/** TikTok default: true. Enable auto-detection of form fields for Advanced Matching. */
|
|
51
|
+
auto_config?: boolean;
|
|
52
|
+
/** TikTok default: false. Restrict data use under U.S. state privacy laws. */
|
|
53
|
+
limited_data_use?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Runtime state — populated by init() and mutated by push(). Not
|
|
56
|
+
* user-facing. Stores last-resolved identity so subsequent pushes with
|
|
57
|
+
* unchanged values skip redundant ttq.identify() calls.
|
|
58
|
+
*/
|
|
59
|
+
_state?: RuntimeState;
|
|
60
|
+
/**
|
|
61
|
+
* Pass-through bucket: any additional TikTok Pixel init config (snake_case
|
|
62
|
+
* keys per TikTok's docs). Merged into ttq.load()'s second argument.
|
|
63
|
+
*/
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
}
|
|
66
|
+
interface RuntimeState {
|
|
67
|
+
lastIdentity?: {
|
|
68
|
+
email?: string;
|
|
69
|
+
phone_number?: string;
|
|
70
|
+
external_id?: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Advanced Matching parameter shape — what settings.identify must resolve to.
|
|
75
|
+
* All fields are optional; if the resolved object has no non-empty values,
|
|
76
|
+
* the destination skips the ttq.identify() call entirely.
|
|
77
|
+
*/
|
|
78
|
+
interface IdentifyParams {
|
|
79
|
+
email?: string;
|
|
80
|
+
phone_number?: string;
|
|
81
|
+
external_id?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Minimal surface of TikTok's window.ttq this destination uses. Tests mock
|
|
85
|
+
* this by attaching a plain object to env.window.ttq; production uses the
|
|
86
|
+
* real SDK created by the snippet setup() call.
|
|
87
|
+
*/
|
|
88
|
+
interface TTQ {
|
|
89
|
+
(...args: unknown[]): void;
|
|
90
|
+
load: (pixelId: string, config?: Record<string, unknown>) => void;
|
|
91
|
+
page: () => void;
|
|
92
|
+
track: (event: string, params?: Record<string, unknown>, options?: {
|
|
93
|
+
event_id?: string;
|
|
94
|
+
}) => void;
|
|
95
|
+
identify: (params: IdentifyParams) => void;
|
|
96
|
+
enableCookie: () => void;
|
|
97
|
+
disableCookie: () => void;
|
|
98
|
+
/** Queue-based pattern — snippet sets this; destination does not read it. */
|
|
99
|
+
methods?: string[];
|
|
100
|
+
/** Internal queue populated before the CDN SDK loads. */
|
|
101
|
+
_i?: Record<string, unknown>;
|
|
102
|
+
/** Flag the snippet sets after the real SDK loads. */
|
|
103
|
+
loaded?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Env — the destination reads `window.ttq` via getEnv(env). Tests attach
|
|
107
|
+
* a mock ttq to env.window; production reads window.ttq created by the
|
|
108
|
+
* SDK snippet.
|
|
109
|
+
*/
|
|
110
|
+
interface Env extends DestinationWeb.Env {
|
|
111
|
+
window: {
|
|
112
|
+
ttq: TTQ;
|
|
113
|
+
};
|
|
114
|
+
document: {
|
|
115
|
+
createElement: (tagName: string) => Element;
|
|
116
|
+
head: {
|
|
117
|
+
appendChild: (node: unknown) => void;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Pre-init env — destination init() call will set up ttq and load the
|
|
124
|
+
* script. Tests receive this as a starting point.
|
|
125
|
+
*/
|
|
126
|
+
declare const init: Env;
|
|
127
|
+
/**
|
|
128
|
+
* Post-init env — same shape; the test runner clones this and replaces
|
|
129
|
+
* individual ttq methods with jest.fn() so it can assert on calls.
|
|
130
|
+
*/
|
|
131
|
+
declare const push: Env;
|
|
132
|
+
/** Simulation tracking paths for CLI --simulate. */
|
|
133
|
+
declare const simulation: string[];
|
|
134
|
+
|
|
135
|
+
declare const env_init: typeof init;
|
|
136
|
+
declare const env_push: typeof push;
|
|
137
|
+
declare const env_simulation: typeof simulation;
|
|
138
|
+
declare namespace env {
|
|
139
|
+
export { env_init as init, env_push as push, env_simulation as simulation };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Examples may optionally carry destination-level settings. The test
|
|
144
|
+
* runner reads `settings` from the example and merges it into the base
|
|
145
|
+
* destination settings on top of the fixed apiKey.
|
|
146
|
+
*/
|
|
147
|
+
type TikTokStepExample = Flow.StepExample & {
|
|
148
|
+
settings?: Partial<Settings>;
|
|
149
|
+
configInclude?: string[];
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Default event forwarding — every walkerOS event becomes a ttq.track()
|
|
153
|
+
* call. With no mapping and no destination-level include, the params
|
|
154
|
+
* object is empty. event_id is always passed as the 3rd argument (TikTok
|
|
155
|
+
* dedup between pixel and Events API).
|
|
156
|
+
*
|
|
157
|
+
* NOTE: The raw walkerOS event name "product view" (with space) is NOT a
|
|
158
|
+
* TikTok standard event. Without a mapping.name override, TikTok treats
|
|
159
|
+
* it as a custom event — functional for audience building, no
|
|
160
|
+
* optimization. The next example shows the recommended override.
|
|
161
|
+
*/
|
|
162
|
+
declare const defaultEventForwarding: TikTokStepExample;
|
|
163
|
+
/**
|
|
164
|
+
* Wildcard ignore — walkerOS's standard way to drop events. The rule
|
|
165
|
+
* matches but does nothing. The destination fires zero SDK calls.
|
|
166
|
+
*/
|
|
167
|
+
declare const wildcardIgnored: TikTokStepExample;
|
|
168
|
+
/**
|
|
169
|
+
* The canonical TikTok pattern: walkerOS "product view" → TikTok
|
|
170
|
+
* "ViewContent" via mapping.name. mapping.data builds the TikTok-native
|
|
171
|
+
* parameter shape (content_type, content_id, content_name, value,
|
|
172
|
+
* currency). include is explicitly set to [] so prefixed walkerOS
|
|
173
|
+
* properties don't leak onto the call and confuse TikTok's matcher.
|
|
174
|
+
*/
|
|
175
|
+
declare const productViewContent: TikTokStepExample;
|
|
176
|
+
/**
|
|
177
|
+
* Destination-level settings.include flattens the walkerOS `data` section
|
|
178
|
+
* into prefixed TikTok event parameters on every push. This is the
|
|
179
|
+
* "dump everything" mode — useful for custom events where TikTok won't
|
|
180
|
+
* do optimization anyway, and no mapping.data is needed.
|
|
181
|
+
*/
|
|
182
|
+
declare const destinationLevelInclude: TikTokStepExample;
|
|
183
|
+
/**
|
|
184
|
+
* Per-rule settings.include REPLACES destination-level include for the
|
|
185
|
+
* matched rule (design doc §6: mapping-level include replaces, not
|
|
186
|
+
* merges with, destination-level include).
|
|
187
|
+
*/
|
|
188
|
+
declare const ruleIncludeReplaces: TikTokStepExample;
|
|
189
|
+
/**
|
|
190
|
+
* Destination-level settings.identify fires on the first push (once the
|
|
191
|
+
* state cache is empty). Advanced Matching parameters (email,
|
|
192
|
+
* phone_number, external_id) are passed to ttq.identify() which
|
|
193
|
+
* auto-hashes them SHA256 before sending. Subsequent pushes with
|
|
194
|
+
* unchanged values do NOT re-fire ttq.identify() — runtime state tracks
|
|
195
|
+
* the last-resolved identity.
|
|
196
|
+
*
|
|
197
|
+
* walkerOS's default user fixture has user.id='us3r' and no email/phone,
|
|
198
|
+
* so the example injects data and maps from there.
|
|
199
|
+
*/
|
|
200
|
+
declare const destinationLevelIdentify: TikTokStepExample;
|
|
201
|
+
/**
|
|
202
|
+
* User registration → CompleteRegistration standard event with per-event
|
|
203
|
+
* identify. The user just provided their email + phone, so this is the
|
|
204
|
+
* moment to fire Advanced Matching for this session. The per-event
|
|
205
|
+
* identify overrides any destination-level identify for this one push.
|
|
206
|
+
*/
|
|
207
|
+
declare const userRegisterCompleteRegistration: TikTokStepExample;
|
|
208
|
+
/**
|
|
209
|
+
* Multi-product order → CompletePayment standard event. The canonical
|
|
210
|
+
* TikTok ecommerce pattern:
|
|
211
|
+
* - mapping.name flips the walkerOS event to TikTok's rigid taxonomy
|
|
212
|
+
* - mapping.data builds the TikTok-native parameter shape
|
|
213
|
+
* - loop iterates event.nested to produce the `contents` array, one
|
|
214
|
+
* entry per product
|
|
215
|
+
* - { key, value: 'EUR' } provides a currency fallback if data.currency
|
|
216
|
+
* is absent (here data.currency is 'EUR' so the key wins)
|
|
217
|
+
*
|
|
218
|
+
* The default "order complete" fixture has 3 nested entries: two
|
|
219
|
+
* products (ers, cc) and one gift (Surprise — no id, no price).
|
|
220
|
+
*/
|
|
221
|
+
declare const orderCompleteCompletePayment: TikTokStepExample;
|
|
222
|
+
/**
|
|
223
|
+
* Search → TikTok Search standard event. Minimal example that shows how
|
|
224
|
+
* a walkerOS search event flips through mapping.name with a single
|
|
225
|
+
* mapping.data field (the query string).
|
|
226
|
+
*/
|
|
227
|
+
declare const searchSubmitSearch: TikTokStepExample;
|
|
228
|
+
/**
|
|
229
|
+
* Consent granted → ttq.enableCookie(). The destination checks the
|
|
230
|
+
* consent keys declared in config.consent (here "marketing" — TikTok is
|
|
231
|
+
* an ad platform, not analytics) and toggles cookie behavior.
|
|
232
|
+
*
|
|
233
|
+
* Uses the canonical StepExample.command='consent' pattern: the test
|
|
234
|
+
* runner dispatches via elb('walker consent', in) instead of pushing
|
|
235
|
+
* an event.
|
|
236
|
+
*/
|
|
237
|
+
declare const consentGrantEnableCookie: TikTokStepExample;
|
|
238
|
+
/**
|
|
239
|
+
* Consent revoked → ttq.disableCookie(). TikTok stops setting and
|
|
240
|
+
* reading its first-party cookie (_ttp) for attribution.
|
|
241
|
+
*/
|
|
242
|
+
declare const consentRevokeDisableCookie: TikTokStepExample;
|
|
243
|
+
|
|
244
|
+
type step_TikTokStepExample = TikTokStepExample;
|
|
245
|
+
declare const step_consentGrantEnableCookie: typeof consentGrantEnableCookie;
|
|
246
|
+
declare const step_consentRevokeDisableCookie: typeof consentRevokeDisableCookie;
|
|
247
|
+
declare const step_defaultEventForwarding: typeof defaultEventForwarding;
|
|
248
|
+
declare const step_destinationLevelIdentify: typeof destinationLevelIdentify;
|
|
249
|
+
declare const step_destinationLevelInclude: typeof destinationLevelInclude;
|
|
250
|
+
declare const step_orderCompleteCompletePayment: typeof orderCompleteCompletePayment;
|
|
251
|
+
declare const step_productViewContent: typeof productViewContent;
|
|
252
|
+
declare const step_ruleIncludeReplaces: typeof ruleIncludeReplaces;
|
|
253
|
+
declare const step_searchSubmitSearch: typeof searchSubmitSearch;
|
|
254
|
+
declare const step_userRegisterCompleteRegistration: typeof userRegisterCompleteRegistration;
|
|
255
|
+
declare const step_wildcardIgnored: typeof wildcardIgnored;
|
|
256
|
+
declare namespace step {
|
|
257
|
+
export { type step_TikTokStepExample as TikTokStepExample, step_consentGrantEnableCookie as consentGrantEnableCookie, step_consentRevokeDisableCookie as consentRevokeDisableCookie, step_defaultEventForwarding as defaultEventForwarding, step_destinationLevelIdentify as destinationLevelIdentify, step_destinationLevelInclude as destinationLevelInclude, step_orderCompleteCompletePayment as orderCompleteCompletePayment, step_productViewContent as productViewContent, step_ruleIncludeReplaces as ruleIncludeReplaces, step_searchSubmitSearch as searchSubmitSearch, step_userRegisterCompleteRegistration as userRegisterCompleteRegistration, step_wildcardIgnored as wildcardIgnored };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
declare const index_env: typeof env;
|
|
261
|
+
declare const index_step: typeof step;
|
|
262
|
+
declare namespace index {
|
|
263
|
+
export { index_env as env, index_step as step };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export { index as examples, index$1 as schemas };
|