Cherry Seed

How do I send TikTok events from PHP?

tiktok php events-api woocommerce server-side wp-remote-post

Quick Answer

Post a JSON payload to the TikTok Events API endpoint from your server using a plain HTTP request. In WordPress that means building the event array, then sending it with wp_remote_post() to TikTok's event track endpoint with your access token in the header. The body carries the event name, an event_id for deduplication, the timestamp, hashed user data, and the value and currency. There's no required PHP SDK, TikTok exposes a REST API, so any server able to make an HTTPS POST can send events, which is why the integration suits WooCommerce hooks cleanly.

Full Answer

The clean pattern hangs the call off a WooCommerce hook. For a purchase you hook woocommerce_payment_complete or the order-status transition, then assemble the payload: an event name TikTok recognises such as CompletePayment, a server-generated event_id, the event timestamp, a properties block with value and currency, and a user block with SHA-256 hashed email and phone plus the IP and user agent.

You then transmit it with WordPress's HTTP API, wp_remote_post(), pointing at TikTok's event track endpoint and passing your access token in the request headers with the JSON body. Keep the access token in server configuration, not in the rendered page, and SHA-256 hash every piece of personal data before it leaves your server. Reading the response matters: a 200 with parse warnings still means dropped fields, so log the body during rollout rather than assuming success.

Two practical notes save grief later. Generate the event_id once and also feed it to the browser Pixel so TikTok deduplicates the matched pair instead of double counting. And fire the call asynchronously or guard it with a short timeout so a slow API response never delays checkout for the customer. With those in place, a few dozen lines of PHP on the right hook give you resilient server-side TikTok tracking without any third-party SDK.

Sources

Programmatic Access

GET https://seresa.io/wp-json/cherry-tree-by-seresa/v1/seeds/708

Cite This Answer

Cherry Tree by Seresa - https://seresa.io/seed/tiktok-tracking/setup-tiktok-server-side-tiktok-php-events