Skip to main content

Track events

Send event data from your web app with Adtrace.trackEvent. Call it only after Adtrace.initSdk.

Important

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:

  1. Create an event in the panel and copy its event token.
  2. Call Adtrace.trackEvent with eventToken and optional parameters.
  3. 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

ParameterTypeDescription
eventTokenstringEvent 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.

ParameterTypeDescription
revenuenumberPositive revenue amount.
currencystringISO 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.

ParameterTypeDescription
callbackParamsarrayArray 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
info

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.

ParameterTypeDescription
partnerParamsarrayArray of { key, value } objects.
Adtrace.trackEvent({
eventToken: '{YourEventToken}',
partnerParams: [
{ key: 'product_id', value: 'sku-42' },
{ key: 'user_id', value: 'user-9' },
],
});
SDK only

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.

ParameterTypeDescription
valueParamsarrayArray 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.

ParameterTypeDescription
deduplicationIdstringUnique 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.

Important

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/';
});