Record an event
POST /api/tracking/collect records a page view, lead or sale for your tracking source, and forwards signed events to Meta and Google Ads.
/api/tracking/collectAuthorization
serverKey The source's server key (atr_server_...), shown to workspace administrators in Settings > Tracking. Send it from your server only, never from a page. Without it, a call is accepted only from an allowed domain, and its events are never forwarded to Meta or Google Ads.
In: header
Query Parameters
The public key of your tracking source (atr_...), shown in Settings > Tracking. You can send it in the x-adrails-key header instead.
^atr_[A-Za-z0-9_-]{20,80}$Header Parameters
Sent by the browser. Must match an allowed domain of the source when the call is not signed with the server key.
uriRequest Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
One event. Text fields are trimmed; an empty string is refused, so leave a field out or send null instead. Unknown fields are ignored.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/tracking/collect?key=<public key>" \ -H "authorization: Bearer <server key>" \ -H "content-type: application/json" \ -d '{ "event_name": "purchase", "event_id": "order-1042", "value": 89.9, "currency": "EUR", "fbc": "fb.1.1759313000000.IwAR2xYz", "fbp": "fb.1.1759312000000.1234567890", "gclid": "Cj0KCQjw9Kk", "user": { "email": "customer@example.com", "external_id": "customer-381" } }'{ "accepted": true, "duplicate": true, "eventId": "order-1042"}/api/tracking/collectQuery Parameters
The public key of your tracking source (atr_...), shown in Settings > Tracking. You can send it in the x-adrails-key header instead.
^atr_[A-Za-z0-9_-]{20,80}$Header Parameters
uriResponse Body
curl -i -X OPTIONS "https://adrails.ai/api/tracking/collect?key=<public key>" \ -H "Origin: https://shop.example.com" \ -H "Access-Control-Request-Method: POST" \ -H "Access-Control-Request-Headers: content-type"