Reference Doc #10
API reference
The gateway's tracking endpoint, the ana.js tracker, responses, rate limits and error codes
The gateway’s tracking API and the ana.js tracker. Sending orders to Watch has its own reference: order webhook API.
Base URLs
| What | URL |
|---|---|
| Gateway (tracking) | https://edge.anacoic.com |
| The app | https://app.anacoic.com |
| Custom domain | https://your-domain.com (if set up) |
Tracking API
POST /track
Primary endpoint for sending events.
curl -X POST https://edge.anacoic.com/track \
-H "Content-Type: application/json" \
-H "X-Gateway-ID: your_gateway_id" \
-d '{
"event_name": "Purchase",
"event_id": "unique-event-id",
"timestamp": 1704067200,
"user": {
"email": "[email protected]",
"phone": "+1234567890",
"external_id": "user_123"
},
"custom_data": {
"value": 99.99,
"currency": "USD",
"transaction_id": "order_123"
}
}'
Headers
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | Must be application/json |
X-Gateway-ID | Yes* | Your gateway ID (*or use ?gid= query param) |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
event_name | string | Yes | Event name (e.g., “Purchase”, “AddToCart”) |
event_id | string | Recommended | Unique ID for deduplication |
timestamp | number | No | Unix timestamp (seconds). Defaults to now. |
user | object | No | User identifiers (see below) |
custom_data | object | No | Event-specific data |
User Object
| Field | Type | Description |
|---|---|---|
email | string | Email address (auto-hashed) |
phone | string | Phone in E.164 format (auto-hashed) |
external_id | string | Your internal user ID (auto-hashed) |
fbp | string | Meta browser ID, the _fbp cookie (auto-captured) |
fbc | string | Meta click ID, the _fbc cookie (auto-captured) |
client_ip_address | string | Auto-extracted if not provided |
client_user_agent | string | Auto-extracted if not provided |
Meta scores Event Match Quality itself and shows it in Events Manager. Sending more of these fields usually helps Meta match events to people, but we don’t estimate the score: check it in Events Manager.
Custom Data
Common fields for e-commerce:
| Field | Type | Description |
|---|---|---|
value | number | Monetary value |
currency | string | ISO 4217 currency code |
transaction_id | string | Unique order/transaction ID |
content_name | string | Product/content name |
content_type | string | ”product”, “article”, etc. |
content_ids | array | Array of product IDs |
num_items | number | Number of items |
Response
Delivered (200, or 207 when only some destinations accepted it):
{
"success": true,
"partiallySuccessful": false,
"requestId": "uuid",
"dispatched_to": ["meta", "tiktok"],
"results": [
{ "success": true, "provider": "meta", "status": 200, "latencyMs": 112 },
{ "success": true, "provider": "tiktok", "status": 200, "latencyMs": 98 }
]
}
If every destination fails, the status is 500 and success is false; each entry in results carries the destination’s error. Signed receipts for AI agents are part of the agent tools, which are coming soon.
Free plan allowance used up (200, not forwarded):
{
"success": true,
"forwarded": false,
"code": "SIGNAL_LIMIT_REACHED",
"message": "Signal received but not forwarded: this plan's 10,000 signals for this billing cycle are used up. Forwarding resumes when the next cycle starts, or right away after an upgrade."
}
Billing blocked (403):
{
"error": "Subscription not active.",
"code": "BILLING_LIMIT"
}
Rate limited (429):
{
"error": "Rate limit exceeded for gateway",
"code": "GATEWAY_RATE_LIMIT",
"retryAfter": 60
}
Gateway not found (404):
{
"error": "Gateway not found"
}
The ana.js tracker
Global Object
When the tracker loads, it exposes window.anacoic:
interface AnacoicSDK {
// Track an event
track: (event: TrackEvent) => void;
// Track a page view
page: (name?: string, properties?: object) => void;
// Identify a user
identify: (userId: string, traits?: object) => void;
// Configuration
config: {
gateway_id: string;
emq_mode: string;
};
}
track()
anacoic.track({
event_name: 'Purchase',
event_id: 'unique-id', // For deduplication
user: {
email: '[email protected]',
phone: '+1234567890'
},
custom_data: {
value: 99.99,
currency: 'USD'
}
});
page()
// Auto-named
anacoic.page();
// Custom name
anacoic.page('Product Detail', {
product_id: 'sku_123'
});
identify()
anacoic.identify('user_123', {
email: '[email protected]',
plan: 'pro'
});
Rate Limits
Each gateway’s limit depends on the plan; every plan also limits each visitor IP to 30 requests per minute.
| Plan | Per gateway |
|---|---|
| Free | 300 requests per minute |
| Pro | 5,000 requests per minute |
| Agency | 15,000 requests per minute |
Past the limit, /track answers 429 (see above) until the next minute.
Error Codes
| Code | Meaning | Resolution |
|---|---|---|
| 200 | Success | — |
| 400 | Bad Request | Check JSON syntax |
| 403 | Forbidden | Check allowed origins; with code: "BILLING_LIMIT", the subscription isn’t active, was canceled, or its payment failed without a payment method on file |
| 404 | Gateway Not Found | Verify gateway ID |
| 429 | Rate Limited | Wait and retry |
| 207 | Some destinations failed | Check results for each destination’s error |
| 500 | Every destination failed | Check results and your destination settings |
| 502 | No destinations configured | Add a destination to the gateway |
Data Retention
| Data Type | Retention | Notes |
|---|---|---|
| Delivery logs | The latest 100 entries per gateway, kept for up to 30 days | Newer entries replace older ones |
| Analytics | 30 days | Aggregated data |
| Health stats | 60 days | Success/error counts |
SDK Installation
NPM (Coming Soon)
npm install @anacoic/sdk
CDN (Current)
<script src="https://edge.anacoic.com/v1/ana.js"
data-gateway="YOUR_GATEWAY_ID"
data-emq="optimize"></script>
Data Attributes
| Attribute | Description |
|---|---|
data-gateway | Your gateway ID (required) |
data-emq | Set to “optimize” to send the page URL with each event (event_source_url), which Meta uses for matching |
data-auto-page | Set to “false” to turn off the automatic PageView |
data-enrich | Set to “true” to add a signed-in customer’s email and ID to each event, when the store’s page exposes them (Shopify, WooCommerce, WordPress) |
Need help? Contact support