Server-Side Client ID
Set up server-side client ID generation for scenarios where the AnyTrack Tracking Tag cannot load. Send PageView events, track conversions with standard events, and enrich data with event attributes using the collect endpoint.
WarningThis is an advanced implementation that requires working knowledge of JavaScript, server-side HTTP requests, and JSON payloads. If you can install the AnyTrack Tracking Tag on your website, use that instead — it handles session creation and event tracking automatically with no code required.
When the AnyTrack Tracking Tag cannot run on your page . Facebook Lead Ads, offline campaigns, headless checkouts, or landing pages you do not control . you can generate a client ID server-side and send events directly to the AnyTrack collect endpoint.
This creates a visitor session without any browser-side JavaScript. Once the session exists, you can track conversions through the webhook endpoint using the click_id or refId parameter, just like any other integration.
ImportantReplace
{propertyid}with your actual AnyTrack Property ID. You can find it in your Property Settings.
How It Works
- Generate a random 14-character alphanumeric
cid(client ID) - POST a JSON payload to the collect endpoint with the
cid, event name, page URL, and timestamp - AnyTrack creates a visitor session tied to that
cid - Send subsequent conversion events through the webhook endpoint using the
click_idorrefId
Collect Endpoint
https://t1.anytrack.io/assets/{propertyid}/collect
Send a POST request with a JSON body containing the following fields.
Collect Payload Fields
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
cid | string | Yes | Client ID: a unique, random 14-character alphanumeric string. You generate this value. | o5p4JFQGh1Yku4 |
en | string | Yes | Event name. Use PageView to create the initial session. | PageView |
ts | string | Yes | Timestamp in milliseconds (Unix epoch). | 1662315001464 |
nc | integer | Yes | New client flag. Set to 1 for a new visitor, 0 for a returning one. | 1 |
dl | string | Yes | Document location. The full page URL including UTM parameters and click IDs. | https://example.com/?utm_source=google&gclid=abc |
dt | string | Yes | Document title. The page title associated with this event. | My Landing Page |
dr | string | No | Document referrer. The URL the visitor came from. | https://google.com |
rid | string | Recommended | External ID from your database (customer ID, lead ID). Use this to resolve identity and attribute conversions via refId instead of click_id. | customer_12345 |
Example Payload
{
"cid": "o5p4JFQGh1Yku4",
"en": "PageView",
"dl": "https://example.com/?utm_source=google&utm_medium=cpc&utm_campaign=tof-campaign&utm_id=12312321&gclid=abc123",
"dt": "My Landing Page",
"dr": "https://google.com",
"nc": 1,
"ts": "1662315001464",
"rid": "lead_98765"
}
NoteInclude all UTM parameters and ad platform click IDs (
gclid,fbclid,ttclid) in thedlfield. AnyTrack parses these automatically to attribute the session to the correct campaign.
How to Generate the cid
cidThe cid is a random 14-character alphanumeric string (a-z, A-Z, 0-9). Each visitor must receive a unique value. Here are examples for common automation tools:
Zapier (Code by Zapier . JavaScript)
// Generates a random 14-character alphanumeric client ID
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let cid = '';
for (let i = 0; i < 14; i++) {
cid += chars.charAt(Math.floor(Math.random() * chars.length));
}
output = [{ cid }];Make (JavaScript Module)
// Use in a Make Custom JavaScript module
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let cid = '';
for (let i = 0; i < 14; i++) {
cid += chars.charAt(Math.floor(Math.random() * chars.length));
}
return cid;Python (Server-Side)
import random
import string
# Generate a 14-character alphanumeric client ID
cid = ''.join(random.choices(string.ascii_letters + string.digits, k=14))Node.js
const crypto = require('crypto');
// Generate a 14-character alphanumeric client ID
const cid = crypto.randomBytes(10).toString('base64url').slice(0, 14);Standard Events
After creating the initial session with a PageView event, you can send conversion events through the AnyTrack webhook endpoint. Use standard event names so AnyTrack automatically maps them to each ad platform's format.
| Event Name | Description | Event Source |
|---|---|---|
PageView | Page view, automatically triggered on page load. Use this to create the initial session via the collect endpoint. | Browser |
ViewContent | User views a product page | Browser |
OutboundClick | User clicks an external link (generates a click_id automatically) | Browser |
AddToCart | User adds an item to cart | Browser & Server-side |
InitiateCheckout | User starts a checkout | Browser & Server-side |
AddPaymentInfo | User adds payment details during checkout | Browser & Server-side |
FormSubmit | User submits an online form | Browser |
Lead | Lead event with a 0 monetary value | Server-side |
CompleteRegistration | Lead event with a monetary value | Server-side |
Purchase | Purchase event with a monetary value | Server-side |
Upsell | Subsequent sale after the initial purchase | Server-side |
Send these events via the webhook endpoint after the session is created:
{
"click_id": "{propertyid}{cid}",
"event_name": "Lead",
"value": 0,
"currency": "USD",
"transactionId": "txn_abc123"
}Or use the refId (external ID) if you passed a rid during session creation:
{
"refid": "lead_98765",
"event_name": "Purchase",
"value": 200,
"currency": "USD",
"transactionId": "order_xyz789"
}
NoteThe
click_idfor server-side sessions is the Property ID concatenated with thecidyou generated:{propertyid}{cid}. If you passed aridduring the collect call, you can userefidinstead. Learn more about using an external ID as click ID.
Enrich Conversions with Event Attributes
Include event attributes in your webhook payload to improve Event Match Quality and give ad platforms richer signals for optimization.
Customer Data
Customer traits are automatically hashed and normalized before being sent to ad platforms. There is no need to hash the data yourself.
| Attribute | Type | Example |
|---|---|---|
email | string | [email protected] |
firstName | string | John |
lastName | string | Smith |
phone | string | +16505554444 |
city | string | Menlo Park |
state | string | CA |
zipcode | string | 94025 |
country | string | US |
Transaction and Product Data
| Attribute | Type | Example |
|---|---|---|
value | number | 142.50 |
currency | string | USD |
transactionId | string | order_xyz789 |
brand | string | Nike |
shippingPrice | number | 9.99 |
taxPrice | number | 12.50 |
items | array | See Product Attributes |
Example: Enriched Purchase Event
{
"refid": "lead_98765",
"event_name": "Purchase",
"value": 142.50,
"currency": "USD",
"transactionId": "order_xyz789",
"email": "[email protected]",
"firstName": "John",
"lastName": "Smith",
"phone": "+16505554444",
"brand": "Nike",
"items": [
{
"id": "SKU-001",
"name": "Air Max 90",
"price": 142.50,
"quantity": 1,
"brand": "Nike",
"category": "Shoes"
}
]
}The more attributes you include, the higher your Event Match Quality score. Higher scores mean better attribution, more accurate lookalike audiences, and improved return on ad spend (ROAS). See the full list of supported attributes in the Event Attributes article.
Use Cases
Facebook and TikTok Lead Ads
Lead ad forms run natively inside the ad platform . your website never loads, so the Tracking Tag cannot execute. Generate a cid server-side when the lead arrives (via Zapier, Make, or the platform's webhook), send a PageView to the collect endpoint with the ad URL and UTM parameters, then send a Lead event through the webhook with the customer's email and phone.
Offline Conversions
Phone calls, in-store visits, and events that happen outside a browser. Create a session with the campaign URL that drove the offline action, then post the conversion event (e.g., Purchase, Lead) when the sale closes. Include customer data for identity matching.
Headless Checkouts and Custom Funnels
Checkout pages hosted on a third-party domain where you cannot install the Tracking Tag. Generate a cid on your server, pass it through the checkout flow, and send InitiateCheckout and Purchase events from your backend when the order completes.
CRM-to-AnyTrack via Zapier or Make
When a CRM status changes (e.g., a lead moves to "Qualified" or "Closed Won" in HubSpot or Salesforce), trigger a Zap or Make scenario that generates a cid, creates a session with the original campaign URL, and sends the appropriate conversion event to AnyTrack.
Landing Pages You Do Not Control
Affiliate campaigns or partner pages where you cannot add JavaScript. Use the rid field to pass your own lead or customer ID during session creation, then track conversions server-side as they happen in your system.
Server-Side Client ID FAQ
FAQ was last reviewed on 2026-04-02
cid) is a unique cookie ID . a random 14-character alphanumeric string that anonymously identifies a user in AnyTrack. When the Tracking Tag runs in the browser, it generates and stores this value as a first-party cookie automatically. In server-side implementations where the Tracking Tag cannot load, you generate the cid yourself and send it to the collect endpoint to create the session manually.cid is the anonymous identifier that makes this possible . it connects a conversion event (like a Purchase or Lead) back to the ad click, UTM parameters, and campaign data that started the journey. Without a cid, AnyTrack has no way to create the user session or build the attribution chain. No cid means no session, no attribution, and no data sent to your ad platforms.refid) is used to alias an AnyTrack cid with an external identifier that you control . such as an email address, phone number, or anonymous ID from your own system. You pass it as rid when creating the session via the collect endpoint. This is often needed when the AnyTrack click_id cannot be passed to your CRM, cart, or conversion source (for example, HubSpot, GoHighLevel, or other CRMs). In simple terms: when AnyTrack tracks an event in the browser, a click_id is generated. When you associate it with an external ID, you are telling AnyTrack: this click_id belongs to [email protected], and every future event I send identified by this email should be matched to the same user.cid) is a unique cookie ID that anonymously identifies a user. The Click ID (click_id) is a unique event identifier generated by the Tracking Tag on the client side . it associates a specific action that a cid performs to a Property ID and a timestamp. All event attributes (customer data, transaction details, product information) are associated to the click_id. In server-side implementations, you generate the cid yourself and construct the click_id by concatenating the Property ID with the cid.cid is a unique 14-character alphanumeric string that identifies a single visitor session. Reusing the same cid across different visitors will merge their data into one session, corrupting attribution. Generate a new random value for every visitor.PageView event via the collect endpoint, then send as many conversion events as needed through the webhook endpoint using the same click_id or refid. For example, you can track Lead, then InitiateCheckout, then Purchase as the customer progresses through your funnel.Updated 14 days ago
