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.
⚠️ Warning
This is an advanced implementation that requires working knowledge of JavaScript, server-side HTTP requests, and JSON payloads. If you can install the Tracking Tag on your website, use that instead — it handles session creation and event tracking automatically with no code required.
When the 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.
❗ Important
Replace
{propertyid}with your actual AnyTrack Property ID. You can find it in your Property Settings.
How It Works
Section titled “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
Section titled “Collect Endpoint”https://t1.anytrack.io/assets/{propertyid}/collectSend a POST request with a JSON body containing the following fields.
Collect Payload Fields
Section titled “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
Section titled “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"}📘 Note
Include 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
Section titled “How to Generate the cid”The 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)
Section titled “Zapier (Code by Zapier — JavaScript)”// Generates a random 14-character alphanumeric client IDconst 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)
Section titled “Make (JavaScript Module)”// Use in a Make Custom JavaScript moduleconst 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)
Section titled “Python (Server-Side)”import randomimport string
# Generate a 14-character alphanumeric client IDcid = ''.join(random.choices(string.ascii_letters + string.digits, k=14))Node.js
Section titled “Node.js”const crypto = require('crypto');
// Generate a 14-character alphanumeric client IDconst cid = crypto.randomBytes(10).toString('base64url').slice(0, 14);Standard Events
Section titled “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"}📘 Note
The
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
Section titled “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
Section titled “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 | jsmith@example.com |
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
Section titled “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
Section titled “Example: Enriched Purchase Event”{ "refid": "lead_98765", "event_name": "Purchase", "value": 142.50, "currency": "USD", "transactionId": "order_xyz789", "email": "jsmith@example.com", "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
Section titled “Use Cases”Facebook and TikTok Lead Ads
Section titled “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
Section titled “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
Section titled “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
Section titled “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
Section titled “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-06-10
What is the AnyTrack Client ID?
Why is the Client ID required to track conversions?
What is an external ID (refid) and why do I need it?
What is the difference between the Client ID and the Click ID?
Does each visitor need a unique cid value?
When should I use server-side client ID instead of the Tracking Tag?
Can I send multiple conversion events after creating a single session?
Which AnyTrack plans support the server-side collect endpoint?
All supported attributes for enriching conversion data and improving Event Match Quality.