Track events
Send event data from your web app with Adtrace.trackEvent. Call it only after Adtrace.initSdk.
Before you send events, ensure the install was successfully tracked. Events sent without a recorded install are stored but not shown in panel statistics.
Typical flow:
- Create an event in the panel and copy its event token.
- Call
Adtrace.trackEventwitheventTokenand optional parameters. - For redirect flows, await the returned promise before navigating away.
Method signature
Adtrace.trackEvent({
eventToken: string,
// optional parameters below
});
Returns a Promise that resolves after the SDK sends the event and receives a backend response.
Required parameters
| Parameter | Type | Description |
|---|---|---|
eventToken | string | Event token from the Adtrace panel. |
Track a simple event
Adtrace.trackEvent({
eventToken: '{YourEventToken}',
});
Record event revenue
Attach revenue to an event when a user completes a purchase or another revenue action.
| Parameter | Type | Description |
|---|---|---|
revenue | number | Positive revenue amount. |
currency | string | ISO currency code such as USD, EUR, or IRR. |
Do not send revenue through value parameters. Always use revenue and currency.
Adtrace.trackEvent({
eventToken: '{YourEventToken}',
revenue: 10,
currency: 'USD',
});
Add callback parameters
Register a callback URL for your event in the panel. Adtrace sends a GET request to that URL when the event is tracked. Add callbackParams to append key-value pairs to the callback URL.
| Parameter | Type | Description |
|---|---|---|
callbackParams | array | Array of { key, value } objects. |
Adtrace.trackEvent({
eventToken: '{YourEventToken}',
callbackParams: [
{ key: 'product_id', value: 'sku-42' },
{ key: 'user_id', value: 'user-9' },
],
});
Example callback request:
https://www.example.com/callback?product_id=sku-42&user_id=user-9
Adtrace does not store custom callback parameters. They are appended only when a callback URL is configured in the panel.
Add partner parameters
Send extra data to network partners configured in the panel.
| Parameter | Type | Description |
|---|---|---|
partnerParams | array | Array of { key, value } objects. |
Adtrace.trackEvent({
eventToken: '{YourEventToken}',
partnerParams: [
{ key: 'product_id', value: 'sku-42' },
{ key: 'user_id', value: 'user-9' },
],
});
Partner parameters are forwarded by the client SDK to enabled network partners.
Add value parameters
Send value parameters activated in the panel or attached to the event payload.
| Parameter | Type | Description |
|---|---|---|
valueParams | array | Array of { key, value } objects. |
Adtrace.trackEvent({
eventToken: '{YourEventToken}',
valueParams: [
{ key: 'level', value: '3' },
{ key: 'score', value: '1250' },
],
});
Do not send revenue in value parameters. Use revenue instead.
Deduplicate events
Provide a deduplicationId to avoid tracking the same logical event twice. The SDK caches recent IDs based on eventDeduplicationListLimit.
| Parameter | Type | Description |
|---|---|---|
deduplicationId | string | Unique ID for this event occurrence. |
Adtrace.trackEvent({
eventToken: '{YourEventToken}',
deduplicationId: 'order-12345',
});
Track then redirect (promise)
trackEvent returns a Promise. Use it when you need to track an event before redirecting the user to another page.
The promise can take noticeable time to settle. Use a timeout so redirects are not blocked indefinitely.
Even if the promise rejects or times out, the SDK keeps the event in its internal queue and retries on the next page load.
Promise.race([
Adtrace.trackEvent({
eventToken: '{YourEventToken}',
}),
new Promise((_, reject) => {
setTimeout(() => reject(new Error('Timed out')), 2000);
}),
])
.catch(() => {
// Event is still queued internally
})
.finally(() => {
window.location.href = 'https://www.example.org/';
});