Guides
Conversions

Events API

Send web, offline and CRM events with SHA-256 data, deduplicate with the Pixel and attribute sales to ads through the ttclid.

The Events API 2.0 receives the conversions that happen outside TikTok (a purchase on your site, an order closed in the CRM) and ties them to the ads. In Mimicr, an event with the ttclid of a click on a sandbox ad shows up in that ad's reports.

The ttclid path

  1. Someone taps the ad. TikTok appends ttclid to the landing page URL. In the sandbox, the traffic.click action or the /mimicr/click/{ad_id} page plays that role:
bash
npx mimicr action tiktok-ads traffic.click adId=1700013373458754
json
{ "ok": true, "action": "traffic.click", "message": "Clique registrado: E.C.P.JKOubGTKTAK3Fp9-F31nqwAAAAMdHslkau2bb-JgWfRPwHKPq4-TVg", "data": { "ttclid": "E.C.P.JKOubGTKTAK3Fp9-F31nqwAAAAMdHslkau2bb-JgWfRPwHKPq4-TVg", "landingUrl": "https://popgas.example/pedido?ttclid=E.C.P.JKOubGTKTAK3Fp9-F31nqwAAAAMdHslkau2bb-JgWfRPwHKPq4-TVg" } }
  1. Your landing page stores the ttclid.
  2. When the conversion happens, your server sends the event with that ttclid.

Send events

bash
curl --request POST \
  --url https://tiktok-ads.mimicr.dev/open_api/v1.3/event/track/ \
  --header 'Access-Token: <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "event_source": "web",
    "event_source_id": "X6R0U4QQZJSZ84ABSF9Q",
    "data": [{
      "event": "Purchase",
      "event_time": 1793956720,
      "event_id": "pedido-48213",
      "user": {
        "ttclid": "E.C.P.JKOubGTKTAK3Fp9-F31nqwAAAAMdHslkau2bb-JgWfRPwHKPq4-TVg",
        "email": "13e2c3f390a91763c2b83e0e6222dfc3c967ef82fc86c3648b00a90d977490de"
      },
      "page": { "url": "https://popgas.example/pedido/obrigado" },
      "properties": { "currency": "BRL", "value": 120.5 }
    }]
  }'
json
{ "code": 0, "message": "OK", "request_id": "20261106124340B63AA0D4F8EFBC937D", "data": {} }
FieldRule
event_sourceweb (Pixel), offline or crm (event set). app is allowlist-only: 40118
event_source_idThe pixel_code (web) or the event set id (offline and CRM). Both are in GET /v1/tiktok-ads
data1 to 1,000 events. Beyond that the whole request is refused
eventStandard events (Purchase, CompleteRegistration, Lead, AddToCart, InitiateCheckout, SubmitForm…) or a custom name on web and CRM. Offline accepts standard ones only
event_timeUnix seconds, in UTC. In Mimicr, at most 7 days in the past and 10 minutes in the future
event_idFor deduplication with the browser Pixel
user.email, user.phone, user.external_idSHA-256 in lowercase hex, a string or a list. Unhashed: 40002 Invalid value for data.0.user.email: not a valid SHA256-hashed string.
user.ttclid, ttp, ip, user_agent, localeNot hashed. Without user.ttclid, Mimicr reads the ttclid= from page.url
page.urlRequired on web
propertiescurrency, value, contents, content_type, content_ids, order_id…
lead.lead_idRequired on CRM: a lead from the forms
test_event_codeThe source's test code; test events never reach reports

Tokens

Two kinds of token work:

  • a Marketing API token with scope 5 (Measurement) that reaches the Pixel's account;
  • the Pixel's own Events API token, in advertisers[].pixels[].events_token of GET /v1/tiktok-ads. It only works for that Pixel; the pixel.rotate_events_token action issues another one and the old one starts answering 40105.

Errors with HTTP status

Unlike the Marketing API, the Events API answers 4xx, and error bodies have no data:

HTTPcodeWhen
40040002Missing or invalid field, unhashed PII, more than 1,000 events. The message points at the first invalid event (data.1.user.email)
40040001No permission to operate pixel code: <code>: unknown source or out of the token's reach
40040105Unknown or revoked token
40140104No token
40140100Over the limit (1,000 events per second)

Deduplication

The key is (event_source_id, event, event_id):

  • a copy within 5 minutes is merged (fields missing from the first one are filled in);
  • a copy within 48 hours is dropped;
  • events without an event_id are never deduplicated.

The response is always code 0; deduplication is invisible to the sender.

Attribution in Mimicr

TikTok does not publish how it attributes. Mimicr does this:

  • a web event whose ttclid came from a click on an ad of the same account, within the ad group's click window (7 days by default), is attributed to that ad;
  • without a ttclid, an event whose hashed e-mail or phone matches a lead of the account is attributed to the lead's ad (on CRM and offline, also by lead_id);
  • the rest is unmatched: accepted, but left out of reports.

An attributed event counts at the click's date and hour: in conversion and result when it is the ad group's optimization_event, and always in the matching website metric (Purchase in complete_payment and value_per_complete_payment, CompleteRegistration in user_registration, Lead and SubmitForm in form). The real_time_* metrics count at the event's date.

To see each event's outcome:

bash
npx mimicr get '/v1/tiktok-ads/events?limit=5'

The status is accepted, merged, deduplicated, test, unmatched or attributed. The conversion.set_outcome action forces attributed or unmatched by eventId or ttclid. The (hashed) e-mail reject@mimicr.dev is always unmatched.