The Gravity pixel tracks page views and auto-detects some conversions client-side. But for the highest fidelity — especially for purchases, signups, and other backend-confirmed events — sending conversions server-to-server is more reliable:
More reliable — server-side calls aren’t affected by browser extensions or network conditions
Richer data — attach customer email, order details, and line items your frontend doesn’t have
Deduplication — use event_id to prevent double-counting across pixel and server events
Offline conversions — attribute phone calls, in-store purchases, and CRM events back to ads
getCAPIData() is safe to call at any time after the pixel loads. If the user arrived via a Gravity ad click, the attribution fields will be populated. If not, they return null — the conversion still records, it just won’t be attributed to a specific ad.The client_context object includes device and environment signals (timezone, screen dimensions, platform) captured by the pixel. Pass the entire object through to your backend and include it in the CAPI request — Gravity uses these signals to improve attribution accuracy.
The client_context object is automatically included by getCAPIData(). It contains device and environment signals that improve conversion quality:
Field
Description
timezone
User’s timezone (e.g. America/New_York)
screen
Screen dimensions and color depth
viewport
Browser viewport dimensions
platform
OS platform (e.g. macOS, Windows)
connection
Network connection type
Pass the entire client_context object through from your frontend to your backend, then include it in the CAPI request — no manipulation is needed on your end. Gravity uses these signals to improve attribution accuracy.
Email address(es) — plaintext OK, auto-hashed before storage
ph
string[]
Phone number(s) in E.164 format
fn
string
First name
ln
string
Last name
external_id
string[]
Your system’s customer/user IDs
PII fields (em, ph, fn, ln) can be sent as plaintext — the API normalizes and SHA-256 hashes them before storage. No plaintext PII is ever persisted. If you prefer to pre-hash, send 64-character hex strings and the API will detect and accept them as-is.
Events are deduplicated by event_id + event_name within a 48-hour window. Always include a unique event_id (e.g., your order ID) to prevent double-counting — especially if you fire both a pixel conversion and a server-side conversion for the same purchase.
Send up to 1,000 events per request by adding more objects to the data array. Each event is processed independently — partial failures don’t reject the batch.