4based/API
← 4based ads tracking
4based

4based TikTok Pixel and Events API tracking

4based TikTok Events API sends every 4based subscription, PPV purchase and tip to TikTok server-side, with the original ttclid click ID and deduplication built in.

Request accessLast updated:

4based TikTok Events API is the server-side bridge between your 4based tracking links and your TikTok ad account. This guide explains how the integration works, what you need before you start, how to set it up step by step, and how to verify that every conversion is counted exactly once.

Browser-only tracking misses a large share of conversions on creator platforms: fans click an ad on mobile, land on a tracking link, and subscribe later inside an in-app browser or on another device. Cookie restrictions, ad blockers and iOS privacy features break the chain. Server-side events from 4based API close that gap by sending the conversion directly from our infrastructure to TikTok, tied back to the original click.

4based API is an independent developer platform. The 4based events described here are part of the 4based API product's normalized event model and are delivered through your own TikTok credentials.

What you get

  • Server-side TikTok conversions for subscriptions, renewals, PPV purchases and tips
  • Automatic ttclid capture on every 4based tracking link
  • Deduplication against the browser pixel with one shared event_id
  • Per-creator ROAS, CPA and LTV reporting in the 4based API dashboard

How does 4based TikTok Pixel and Events API tracking work?

  1. 1

    Ad click

    A fan taps your TikTok ad and TikTok appends ttclid to the URL.

  2. 2

    Tracking link

    Your 4based tracking link saves ttclid as a first-party value for 90 days.

  3. 3

    4based conversion

    The fan subscribes, renews, buys a PPV message or sends a tip on 4based.

  4. 4

    4based API

    We hash identifiers, assign one event_id, apply consent and sign the event.

  5. 5

    TikTok

    The event is posted to TikTok and appears in reporting within minutes.

Before you start

  • An active TikTok ad account with admin or advertiser access
  • Your pixel code
  • A Events API access token
  • At least one 4based tracking link for the creator you are promoting
  • A 4based API key from your dashboard (request access if you do not have one yet)

Step-by-step setup

  1. 1. Create the pixel or dataset

    Open TikTok Events Manager, create a new pixel code for the creator's funnel and copy its ID. One pixel code per creator keeps reporting clean, but agencies can also share one across a roster.

    pixel code: 1234567890

    Status: Active

    Source: Website

  2. 2. Generate the access token

    In the pixel code settings generate a Events API access token. Store it like a password: anyone who has it can send events to your account.

    Token: EAAG....(hidden)

    Created: today

    Permissions: send events

  3. 3. Connect in the 4based API dashboard

    Open Ads Tracking in the dashboard, choose TikTok, paste the pixel code and token, and pick which creators the connection applies to. 4based API validates the credentials immediately.

    TikTok: Connected

    Creators: 3 selected

    Validation: OK

  4. 4. Add the tracking link to your ads

    Use your 4based tracking link as the destination URL in every TikTok ad. Do not strip query parameters: ttclid must reach the landing page. Add the click capture snippet below if you host your own landing page.

    Destination: link.example.com/summer

    Auto-tag: ttclid on

    UTM: preserved

  5. 5. Map 4based events

    Review the default mapping from 4based events to TikTok events and turn on the events you want to optimize for. Values and currency are filled in automatically from the transaction.

    Subscribe: on

    Purchase (PPV, tip, renewal): on

    Lead: on

  6. 6. Send a test event

    Use Events Manager > Test Events to get a test code, paste it into the dashboard and send a test event. A good result appears within a minute and shows the expected identifiers.

    Test event: Purchase

    Status: Received

    Matched identifiers: 4

Capture the click ID

Fans may convert hours or days after the click, so ttclid must survive the session. If you use a 4based API hosted tracking link this happens automatically. If you run your own landing page, add this snippet. It reads ttclid from the URL and stores it in a first-party cookie for 90 days.

capture-click-id.ts
// capture-click-id.ts - runs on your tracking-link landing page
const PARAMS = ["ttclid"];
const NINETY_DAYS = 60 * 60 * 24 * 90;
const url = new URL(window.location.href);
for (const name of PARAMS) {
  const value = url.searchParams.get(name);
  if (!value) continue;
  document.cookie = `4b_${name}=${encodeURIComponent(value)}; Max-Age=${NINETY_DAYS}; Path=/; SameSite=Lax; Secure`;
}
// The 4based API tracking link reads this cookie and stores the click ID with the fan.

Event mapping

The table shows how each 4based event maps to TikTok, with required and recommended parameters. Required parameters are always sent; recommended parameters are sent when the data is available and consent allows it.

4based eventTikTokRequiredRecommended
Tracking link clickClickButtonevent, event_time, event_id, page.urlttclid, user_agent
Free follow / signupSubmitFormevent, event_id, user.email (hashed)ttclid, ip
New subscriptionSubscribeevent_id, value, currencyttclid, external_id
RenewalCompletePaymentevent_id, value, currencycontent_type: subscription
PPV message purchaseCompletePaymentevent_id, value, currencycontent_type: ppv
TipCompletePaymentevent_id, value, currencycontent_type: tip

Full payload example

You call one 4based API endpoint (POST https://api.4basedapi.com/v1/ads/tiktok/events). 4based API translates it into the TikTok request (POST https://business-api.tiktok.com/open_api/v1.3/event/track/). The examples below send a purchase event in cURL, TypeScript and Python.

curl -X POST https://api.4basedapi.com/v1/ads/tiktok/events \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "pixel_code": "C4XXXXXXXXXXXXX",
    "event_source": "web",
    "test_event_code": "TEST12345",
    "event": "CompletePayment",
    "event_id": "4based_sub_abc123",
    "event_time": 1717000000,
    "context": {
      "user": { "email": "<sha256(email)>", "ttp": "<_ttp cookie>" },
      "ad": { "callback": "<ttclid>" },
      "page": { "url": "https://link.example.com/summer" }
    },
    "properties": { "currency": "USD", "value": 9.99 }
  }'

How does ttclid travel from the ad to the conversion?

TikTok appends ttclid to the landing URL when a fan taps your ad. The landing script stores it in a first-party cookie, and if the TikTok Pixel is installed it also sets _ttp, the browser identifier. 4based API attaches both to the fan record created by your tracking link and sends ttclid as context.ad.callback on every later event.

Under the hood 4based API calls POST https://business-api.tiktok.com/open_api/v1.3/event/track/ with event_source: "web" and event_source_id set to your pixel code. You send one request to the 4based API endpoint and the platform handles the version, the access token header and the payload shape.

Which events should you optimize for?

Most 4based campaigns optimize for CompletePayment once enough volume exists, and for Subscribe while a new pixel is still learning. SubmitForm is useful for free-follow funnels where the first step is a signup rather than a payment. Custom properties such as content_type tell TikTok whether a payment was a renewal, a PPV purchase or a tip, which keeps reporting clean.

Deduplication

If you run the TikTok browser pixel alongside server events, both will report the same conversion. To avoid double counting, both must carry the same identifier: event_id.

4based API generates the event_id from the 4based transaction, for example 4based_sub_abc123 for a subscription or 4based_ppv_msg5531 for a PPV purchase. If you fire the browser event yourself, read the same value from the tracking-link data layer and pass it to the browser call.

TikTok keeps the first event it receives and discards later duplicates within its deduplication window. Server events usually arrive first, so the browser event mainly adds extra signal.

Matching and privacy

Emails are trimmed, lowercased and hashed with SHA-256 before they leave 4based API. Phone numbers are normalized to E.164 and hashed the same way. Raw personal data is never sent to any ad platform.

Fields sent to TikTok: hashed email when available, ttclid, _ttp when present, client IP address and user agent from the click, event_id, value and currency. Nothing else is sent.

Consent is respected end to end. 4based API reads IAB TCF v2.2 strings and Google Consent Mode v2 signals recorded on the tracking link. Without advertising consent, hashed identifiers are withheld, and in consent regions the event is blocked entirely. Hashing is not anonymization, so treat hashed identifiers as personal data.

Test and verify

Open Events Manager > Test Events. Copy the test code and paste it into the TikTok connection in the 4based API dashboard, then click Send test event.

A good result shows the event within a minute with the correct event name, value and currency, plus at least the click ID and one more identifier. Remove the test code once you are done, otherwise live events may be routed to the test view.

After going live, compare conversions in TikTok with the 4based API dashboard for the same day. Differences under 5 percent are normal because of attribution windows and time zones.

Troubleshooting

SymptomCauseFix
No events in test viewTest code missing or expiredGenerate a new test code and paste it again
Events arrive without ttclidQuery parameters stripped by a redirectUse the tracking link directly as the ad destination
Conversions counted twiceBrowser and server events use different IDsPass the same event_id to the browser call
Invalid token errorToken revoked or for another accountGenerate a new token and reconnect
Low match qualityMissing IP, user agent or emailEnable click context capture and hashed email with consent
Wrong currency or valueCreator currency not setSet the default currency per creator in the dashboard
Events blockedNo advertising consent recordedCheck the consent banner on your landing page

Frequently asked questions

Create a pixel in TikTok Events Manager, generate an Events API access token and add both to the 4based API dashboard. Conversions are sent with the ttclid captured on your tracking link.

Build with 4based API

Ready to build?

Tell us what you want to automate, measure or build on top of 4based. Agencies, developers and automation teams all get a tailored next step from our team.