TrustData
Connectors

Custom webhooks

Send server-side events to TrustData via HTTP POST requests.

Custom webhooks let you send conversion events (purchases, leads, sign-ups) to TrustData from your server, CRM, or any platform that can make HTTP requests.

How it works

Instead of relying on browser-side tracking, you POST a JSON payload to a TrustData endpoint. TrustData matches the event to a tracked session and attributes it to the correct ad campaign.

Loading diagram…

Setup

Enable webhook receiving

  1. Go to Settings → Attribution IDs → select your ID
  2. Open the Receiving tab
  3. Under Webhook receiving, turn on Accept incoming webhooks
  4. Click Save receiving

Once saved, the Endpoint, Webhook keys, and Recent activity sections appear below the form.

Generate an API key

  1. In Webhook keys, click Generate key
  2. Enter a Key name (e.g., Backend prod, Shopify prod)
  3. Click Generate key
  4. Copy the key immediately. TrustData shows it only once

Keys use the format td_wh_<random>. TrustData stores only the key prefix. The full key cannot be recovered after creation. If you lose the key, revoke it and generate a new one.


Endpoint

POST https://t.trustdata.tech/webhooks/custom/{attribution_id}/{topic}
Path parameterDescription
attribution_idYour attribution ID from Settings → Attribution IDs
topicEvent type (see table below)
If you have a verified custom tracking domain, use it instead of t.trustdata.tech.

Topics

You can also send the topic in the X-Webhook-Topic header. The path value wins. A request with neither returns 400.

TopicEquivalent SDK eventDescriptionForwarded to ad platforms
purchasepurchaseCompleted transactionYes
generate_leadgenerate_leadLead form submissionYes
leadgenerate_leadOlder name for generate_lead, accepted as sentYes
signupsign_upAccount registrationYes
subscriptionn/aSubscription startedYes
custom(any name)Custom eventYes
refundn/aOrder refundedNo
order_updaten/aA change to an existing orderNo
qualify_leadn/aLater lead stageNo
working_leadn/aLater lead stageNo
close_convert_leadn/aLater lead stageNo
close_unconvert_leadn/aLater lead stageNo
disqualify_leadn/aLater lead stageNo

TrustData stores every topic in the list. A topic in the last column is never sent to an ad platform. A topic outside the list is accepted but stored without the fields TrustData reads from the payload, and is not forwarded.

Forwarding to an ad platform also needs consent.advertising set to true and a non-empty conversion_id. See Consent.


Authentication

Send a webhook key or a signature. A request with neither returns 401.

Webhook key

HeaderValue
AuthorizationBearer td_wh_...
Content-Typeapplication/json

The Authorization header also accepts the key without the Bearer prefix. A key works only for the attribution ID it was generated for. A key for another attribution ID returns 403. If the key has an IP allowlist, a request from another address returns 401.

HMAC signature

Instead of a key, you can sign the request body with your property's webhook signing secret.

HeaderValue
X-Webhook-SignatureHMAC-SHA256 of the raw request body, hex or base64 encoded
Content-Typeapplication/json

A sha256= prefix on the signature is accepted. TrustData creates the signing secret when you turn on Accept incoming webhooks. The dashboard does not display it. If the property has no secret, the request returns 401 with no signing secret configured.

SIGNATURE=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET" | cut -d' ' -f2)

curl -X POST \
  https://t.trustdata.tech/webhooks/custom/YOUR_ATTRIBUTION_ID/purchase \
  -H "X-Webhook-Signature: sha256=$SIGNATURE" \
  -H "Content-Type: application/json" \
  -d "$PAYLOAD"

Payload

The webhook payload uses the same schema as the JavaScript SDK, with the same field names and the same objects. See the Event schema for the full reference.

A minimal purchase example:

{
  "conversion_id": "ORD-12345",
  "value": 149.99,
  "currency": "USD",
  "user_data": {
    "email": "customer@example.com"
  }
}

A complete purchase with all signals:

{
  "conversion_id": "ORD-12345",
  "value": 149.99,
  "currency": "USD",
  "tax": 12.50,
  "shipping": 5.99,
  "discount_code": "SUMMER20",
  "user_data": {
    "email": "customer@example.com",
    "phone": "+15551234567",
    "first_name": "Jane",
    "last_name": "Doe",
    "address": {
      "city": "New York",
      "region": "NY",
      "postal_code": "10001",
      "country": "US"
    }
  },
  "items": [
    {
      "item_id": "SKU123",
      "item_name": "Widget Pro",
      "quantity": 2,
      "price": 49.99
    }
  ],
  "consent": {
    "analytics": true,
    "advertising": true
  }
}

Fields

FieldTypeDescription
conversion_idstringYour identifier for the conversion. You can send transaction_id instead. An empty value blocks forwarding to ad platforms
event_idstringOptional. TrustData builds the event ID it returns and forwards as custom_<event_id>. Without it, the ID is custom_<conversion_id>
event_timenumber or stringUnix seconds or an RFC 3339 string. If absent, zero or negative, TrustData uses the time it received the request. A future time becomes the receive time
valuenumberConversion value. On the refund topic a positive value becomes negative
currencystringISO 4217 code. TrustData converts it to uppercase
visitor_idstringThe SDK visitor ID, used for session matching
consentobjectanalytics, advertising, preferences and sale_of_data, each a boolean. See Consent
user_dataobjectemail, email_sha256, phone, first_name, last_name and address (street, city, region, postal_code, country)
itemsarrayOne object per product. Each item takes item_id, item_name, price, quantity and the other item fields. The older names products, id and name are still accepted

email_sha256 is the lowercase hex SHA-256 of the lowercased, trimmed email address. TrustData ignores a value that is not a 64-character hex digest. Send numbers as JSON numbers: a number sent as a string is ignored.

Any other top-level key is stored as a field of the order.

An absent consent object sets every flag to false. TrustData records the conversion, its value and its attribution whatever the consent. The flags change what else it keeps:

  • Without advertising, TrustData drops the plaintext user_data and the raw payload, and forwards nothing to ad platforms.
  • With analytics and without advertising, TrustData keeps user_data.email_sha256 if you sent one. It does not hash a plaintext email.
  • With neither flag, TrustData stores no user_data.

Send the real consent state on every request.


Examples

Purchase

curl -X POST \
  https://t.trustdata.tech/webhooks/custom/YOUR_ATTRIBUTION_ID/purchase \
  -H "Authorization: Bearer td_wh_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "conversion_id": "ORD-12345",
    "value": 149.99,
    "currency": "USD",
    "user_data": {
      "email": "customer@example.com",
      "phone": "+15551234567"
    },
    "consent": { "analytics": true, "advertising": true }
  }'

Lead

curl -X POST \
  https://t.trustdata.tech/webhooks/custom/YOUR_ATTRIBUTION_ID/lead \
  -H "Authorization: Bearer td_wh_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "conversion_id": "lead_abc789",
    "value": 50,
    "currency": "USD",
    "lead_type": "demo_request",
    "user_data": {
      "email": "prospect@example.com"
    },
    "consent": { "analytics": true, "advertising": true }
  }'

Session matching

TrustData links the incoming webhook to a browser session it has already tracked. The session match is what ties the conversion back to the ad click that drove it.

Matching uses visitor_id, the anonymous ID the JavaScript SDK assigns to the visitor. Pass it from your frontend to your backend when a conversion occurs.

// Frontend: get the visitor ID at checkout
const visitorId = trustdata.getVisitorId();
// Pass visitorId to your backend with the order
{
  "conversion_id": "ORD-12345",
  "visitor_id": "the-id-from-getVisitorId",
  "value": 149.99,
  "currency": "USD"
}

TrustData uses user_data (email, phone) for enhanced conversion forwarding to ad platforms, not for session matching.

When TrustData finds a match, it attributes the conversion to the campaign and forwards it to ad platforms.


Viewing webhook activity

The Recent activity section in the Receiving tab shows the last 20 requests:

ColumnDescription
EventThe topic you sent, when it arrived, and the source (for example custom or woocommerce)
StatusThe HTTP status code TrustData returned (200, 401, 429…)
IPThe IP address the request came from

Responses

A successful request returns 200 with this body:

{
  "success": true,
  "matched": true,
  "event_id": "custom_ORD-12345",
  "visitor_id": "the-id-from-getVisitorId",
  "session_id": "",
  "conversion_forwarded": true
}

Every error body is {"success": false, "error": "<message>"}.

Check success in every response. If TrustData accepts the request but fails while saving the conversion, it still returns HTTP 200, with {"success": false, "error": "..."}. A client that reads only the status code treats a dropped conversion as delivered.
StatusCause
400The URL has no attribution ID or no topic, or the body is not valid JSON
401The webhook key is unknown, revoked or expired. Or the request has neither a key nor a signature. Or the signature does not match. Or the property has no signing secret
403The webhook key belongs to another attribution ID
405The method is not POST
429Too many requests from your IP address. The response carries a Retry-After header

An attribution ID that does not exist returns 403 when you send a webhook key and 401 when you send a signature. The collector does not check whether Accept incoming webhooks is on.


Rate limits

TrustData limits requests per IP address. A request over the limit returns 429 with a Retry-After header. No limit applies per webhook key.


Troubleshooting

401 Unauthorized

  • Confirm the header format: Authorization: Bearer td_wh_...
  • Verify the webhook key is active (not revoked or expired)
  • Confirm there is no extra whitespace around the token
  • If the key has an IP allowlist, confirm the request comes from an allowed address
  • If you sign requests, sign the exact raw body and send the result in X-Webhook-Signature
  • no signing secret configured means the property has no signing secret. Turn on Accept incoming webhooks and save, or send a webhook key

403 Forbidden

  • Verify the attribution ID in the URL. The webhook key works only for the attribution ID it was generated for

429 Too Many Requests

  • Your IP address exceeded the rate limit
  • Wait for the Retry-After period, then retry

Event not attributed

  • Check Recent activity. A 200 status means TrustData received the event. If it is still not attributed, TrustData did not link it to a visitor
  • Confirm the payload includes visitor_id, the primary matching signal (use trustdata.getVisitorId())
  • Confirm the TrustData SDK is installed on your landing pages. TrustData must track the session before it can match the conversion
  • Check that the event arrived within the lookback window (default: 30 days from click)