TrustData
Tracking SDK

Events reference

Track page views and conversions with TrustData.

TrustData tracks two types of events: page views and conversions.

Page views

Page views are tracked automatically when you initialize the SDK with sendPageView: true:

trustdata.push(['init', 'YOUR_ATTRIBUTION_ID', { sendPageView: true }]);

Each page view captures:

  • Current URL and referrer
  • UTM parameters
  • TrustData tracking parameters
  • Click IDs from ad platforms
  • Visitor and session identifiers
  • Consent and adblock status

Single page applications (SPAs)

For SPAs (React, Vue, etc.), track page views on route changes:

// After route change
trustdata.push(['event', 'page_view']);

Conversions

Conversions are the events that matter for attribution. TrustData supports two primary conversion types:

Purchase

For e-commerce transactions:

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

Full example with products and user data:

trustdata.push(['event', 'purchase', {
  conversion_id: 'ORD-12345',
  value: 149.99,
  currency: 'USD',
  tax: 12.50,
  shipping: 5.99,
  user_data: {
    email: '[email protected]',
    phone: '+15551234567',
    first_name: 'Jane',
    last_name: 'Doe',
  },
  products: [
    {
      id: 'SKU123',
      name: 'Premium Widget',
      quantity: 2,
      price: 49.99,
    },
    {
      id: 'SKU456',
      name: 'Widget Accessory',
      quantity: 1,
      price: 50.01,
    },
  ],
}]);

Generate lead

For lead generation (demo requests, form submissions, signups):

trustdata.push(['event', 'generate_lead', {
  conversion_id: 'lead_abc789',
  value: 50,
  currency: 'USD',
  lead_type: 'demo_request',
  user_data: {
    email: '[email protected]',
  },
}]);

Examples:

// Demo request
trustdata.push(['event', 'generate_lead', {
  conversion_id: 'lead_abc789',
  value: 100,
  currency: 'USD',
  lead_type: 'demo_request',
  user_data: { email: '[email protected]' },
}]);

// Newsletter signup
trustdata.push(['event', 'generate_lead', {
  conversion_id: 'sub_xyz123',
  value: 10,
  currency: 'USD',
  lead_type: 'newsletter',
  user_data: { email: '[email protected]' },
}]);

// Contact form
trustdata.push(['event', 'generate_lead', {
  conversion_id: 'form_456',
  value: 50,
  currency: 'USD',
  lead_type: 'contact_form',
  user_data: { email: '[email protected]' },
}]);

URL parameters

TrustData automatically captures parameters from the URL to enable attribution.

TrustData parameters

Add these to your ad URLs for campaign tracking:

ParameterPurposeExample
trdt_cpidCampaign ID?trdt_cpid={campaignid}
trdt_agidAd Group ID&trdt_agid={adgroupid}
trdt_kwidKeyword ID&trdt_kwid={targetid}
trdt_ctidCreative/Ad ID&trdt_ctid={creative}

Example URL:

https://example.com/landing?trdt_cpid=123&trdt_agid=456&trdt_ctid=789

UTM parameters

Standard UTM parameters are captured automatically:

ParameterPurpose
utm_sourceTraffic source (google, facebook, newsletter)
utm_mediumMarketing medium (cpc, email, social)
utm_campaignCampaign name
utm_termPaid search keyword
utm_contentAd variation or link identifier

Ad platform click IDs

These are added automatically by ad platforms:

ParameterPlatform
gclidGoogle Ads
fbclidMeta Ads
ttclidTikTok Ads
msclkidMicrosoft Ads

If the user consents, TrustData captures these click IDs and uses them to match conversions back to the original ad click.

Automatically captured data

Every event includes:

PropertyDescription
timestampEvent time (ISO 8601)
urlCurrent page URL
referrerReferring URL
visitor_idPersistent visitor identifier
deviceDevice type, browser, OS
consentConsent state (4 levels)
adblockWhether ad blocker detected
For the full payload reference — all fields, objects, and what to prioritize for maximum accuracy — see the Event schema.

Best practices

1. Always include conversion_id

Include a unique conversion_id on every conversion event to prevent duplicate attribution:

trustdata.push(['event', 'purchase', {
  conversion_id: 'ORD-12345',  // your order ID, lead ID, form ID, etc.
  value: 149.99,
  currency: 'USD',
}]);

2. Always include value

Attribution depends on conversion value. Always include it:

// Good
trustdata.push(['event', 'generate_lead', {
  conversion_id: 'lead_abc',
  value: 50,
  currency: 'USD',
}]);

// Bad - no value or dedup ID
trustdata.push(['event', 'generate_lead']);