TrustData
Tracking

Event schema

Canonical reference for event types and payload fields across the JavaScript SDK and webhook API.

This is the single source of truth for TrustData's event schema. The JavaScript SDK and the webhook API share field names, objects and structure. They differ in who sets identity and consent. The SDK sets visitor_id, user_id and consent itself, and discards any value you pass for them in event(). In a webhook you send all three in the payload. The sections below say where the two differ.

Event types

SDK event nameWebhook topicDescription
purchasepurchaseCompleted transaction
generate_leadgenerate_lead or leadLead form submission. lead is the older topic name and stays accepted
sign_upsignupAccount registration
page_viewn/aPage view (SDK only)
page_leave, user_engagementn/aEngagement events sent automatically by the SDK
identity_linkn/aSent by linkIdentity() after a consent upgrade (SDK only)
consent_decisionn/aSent automatically when consent() is called with { interaction: true } (SDK only)
funnel_stepn/aA funnel step, sent from the GTM template
n/aorder_updateA change to an earlier order (webhook only)
n/aqualify_lead, working_lead, close_convert_lead, close_unconvert_lead, disqualify_leadLater lead stages (webhook only)
n/arefundOrder refunded (webhook only)
n/asubscriptionSubscription started (webhook only)
(any name)customCustom event

TrustData stores order_update, refund and the later lead stages but never forwards them to an ad platform.


Core fields

FieldTypeKeyDescription
Conversion IDstringconversion_idUnique ID for deduplication. Use your internal ID (order ID, lead ID, form submission ID, etc.). transaction_id is read as a fallback.
ValuenumbervalueConversion value. Decimal, not cents (e.g., 99.00).
CurrencystringcurrencyISO 4217 code (e.g., USD, EUR, GBP).

The collector does not reject an event without conversion_id. It stores the event, but it does not forward it to an ad platform. Forwarding also needs advertising consent on the event.


user_data object

TrustData uses user data for session matching and enhanced conversion forwarding to ad platforms (Meta CAPI, Google Ads, TikTok Events API). It hashes all fields before sending them to any platform.

// SDK: set the user once, the SDK hashes email and phone and adds them to later events
trustdata.setUser({
  email: '[email protected]',
  phone: '+15551234567',
  first_name: 'Jane',
  last_name: 'Doe',
  address: {
    street: '123 Main St',
    city: 'New York',
    region: 'NY',
    postal_code: '10001',
    country: 'US'
  }
});

trustdata.push(['event', 'generate_lead', {
  conversion_id: 'lead_abc789',
  value: 50,
  currency: 'USD'
}]);
// Webhook: same structure, sent in the payload
{
  "conversion_id": "lead_abc789",
  "value": 50,
  "currency": "USD",
  "user_data": {
    "email": "[email protected]",
    "phone": "+15551234567",
    "first_name": "Jane",
    "last_name": "Doe",
    "address": {
      "street": "123 Main St",
      "city": "New York",
      "region": "NY",
      "postal_code": "10001",
      "country": "US"
    }
  }
}

How the SDK and the collector treat user_data:

  • setUser(). The SDK hashes email and phone with SHA-256 in the browser and adds the stored data to every event as user_data. It does so only while the visitor has advertising consent. This data replaces any user_data you pass in event().
  • user_data in event(). Without a prior setUser(), the SDK sends your user_data as written. It does not hash it. Prefer setUser().
  • At the collector. The collector keeps user_data only when the event has advertising consent, and drops it otherwise. A value that is a SHA-256 hex digest is kept as a digest. Any other email or phone is read as plain text.
  • Webhooks. Without advertising consent, the collector drops user_data from a webhook as well. It keeps only an email hash you supplied, and only when the event has analytics consent.

user_data fields

FieldTypeDescription
user_data.emailstringCustomer email
user_data.phonestringE.164 format (e.g., +15551234567)
user_data.first_namestring
user_data.last_namestring
user_data.address.streetstring
user_data.address.citystring
user_data.address.regionstringState or province
user_data.address.postal_codestringZIP or postal code
user_data.address.countrystringISO 3166-1 alpha-2 (e.g., US, FR)

items array

Line items for purchase events.

// SDK
trustdata.push(['event', 'purchase', {
  conversion_id: 'ORD-12345',
  value: 149.99,
  currency: 'USD',
  items: [
    {
      item_id: 'SKU123',
      item_name: 'Widget Pro',
      quantity: 2,
      price: 49.99,
    }
  ]
}]);
// Webhook: same structure
{
  "conversion_id": "ORD-12345",
  "value": 149.99,
  "currency": "USD",
  "items": [
    {
      "item_id": "SKU123",
      "item_name": "Widget Pro",
      "quantity": 2,
      "price": 49.99
    }
  ]
}

items fields

FieldTypeDescription
item_idstringProduct identifier. Required
item_namestringProduct display name. Required
pricenumberUnit price, greater than 0. Required
quantityintegerQuantity ordered. Defaults to 1
currencystringISO 4217 code, if it differs from the event currency
variant_idstringVariant identifier
skustringStock keeping unit
item_variantstringVariant name (e.g., Blue / Large)
item_brandstringBrand name
item_categorystringProduct category
categoriesarray of stringsCategory path, for example ["Apparel", "Shoes"]
image_urlstringProduct image URL
urlstringProduct page URL

TrustData skips an item that is missing item_id, item_name, or a positive price. The exception is an item that carries a ref, which TrustData keeps without them. Any other field you add to an item is kept as a custom item field.

Other fields TrustData reads on an item: discount, cost and compare_at_price.

Older names. TrustData still accepts the names it used before: products for the list, and id, name, brand, category, variant_title and total_discount on each item. If an item carries both spellings, the name in the table wins. Use the names in the table in new code.


Consent state for the event. Where you set it depends on the channel.

SDK. Set consent with trustdata.consent() or the consent option of init. The SDK adds the consent object to every event from that state. A consent value passed to event() is discarded.

// SDK
trustdata.consent({ analytics: true, advertising: true });

trustdata.push(['event', 'purchase', {
  conversion_id: 'ORD-12345',
  value: 149.99,
  currency: 'USD'
}]);

Webhook. Send the consent object in the payload. If you leave it out, the collector treats all four levels as false.

{
  "conversion_id": "ORD-12345",
  "value": 149.99,
  "currency": "USD",
  "consent": {
    "analytics": true,
    "advertising": true
  }
}
FieldTypeDescription
consent.analyticsbooleanAnalytics and measurement consent
consent.advertisingbooleanAd targeting and remarketing consent
consent.preferencesbooleanFunctional / preferences consent
consent.sale_of_databooleanThird-party data sharing opt-out (CCPA)

Purchase fields

FieldTypeDescription
taxnumberTax amount
shippingnumberShipping cost
discount_codestringApplied discount or coupon code
discountnumberDiscount amount

Lead fields

FieldTypeDescription
lead_typestringLead category (e.g., demo_request, contact_form, newsletter)

Custom fields

TrustData stores any additional fields as event metadata. They don't affect attribution or conversion forwarding.


What to send for maximum accuracy

PriorityFieldWhy it matters
Criticalconversion_idPrevents double-counting
Criticalvalue + currencyRequired for ROAS and bidding signals
Highuser_data.emailSession matching and enhanced conversions
HighFull user_dataEnables enhanced conversions to Meta, Google, TikTok
MediumitemsProduct-level reporting and catalog matching
MediumconsentAccurate consent-aware attribution
LowCustom fieldsStored for analysis, not used for attribution