Documentation
Event Tracking API
The ChannelStack Event Tracking API allows you to send conversion events from your website or application to multiple advertising platforms simultaneously. We handle data formatting, hashing, and delivery to each network's specific requirements.
Basic Usage
// JavaScript/TypeScript
// This is a standard HTTP API - you can convert it to any language (Python, etc.)
const response = await fetch('https://api.channelstack.dev/v1/track', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
api_key: 'YOUR_API_KEY_HERE', // Replace with 'key_...'
event: 'signed_up',
email: 'user@example.com', // Raw email - we handle hashing
// See https://channelstack.dev/docs/events#fields for all fields
// Tip: Add Click IDs to significantly improve ad performance
}),
})
Field Reference
Include additional fields to improve match rates and attribution accuracy across ad platforms. All fields except api_key
and event
are optional.
Required Fields
Field | Type | Description |
---|---|---|
api_key | string | Your ChannelStack API key |
event | string | Event name (e.g., "signed_up", "purchase_completed") |
User Identification
These fields help match events to users who clicked your ads. More fields = better match rates.
Field | Description |
---|---|
email | Email address - auto-hashed with SHA-256 |
phone | Phone number - format: +1234567890 |
distinct_id | Your internal user ID |
first_name | User's first name |
last_name | User's last name |
city | City name |
state | 2-letter state code (e.g., "CA") |
zip | Postal/ZIP code |
country | 2-letter country code (e.g., "US") |
Click IDs
Click IDs link events directly to ad clicks for accurate attribution.
Field | Platform | Source |
---|---|---|
gclid | Google Ads | URL parameter |
fbc | Meta | _fbc cookie |
fbp | Meta | _fbp cookie |
ttclid | TikTok | URL parameter |
gbraid | Google (iOS App) | URL parameter |
wbraid | Google (iOS Web) | URL parameter |
Purchase Event Fields
Required for purchase events to calculate ROAS and optimize for value.
Field | Description | Example |
---|---|---|
value | Purchase amount | 99.99 |
currency | 3-letter currency code (ISO 4217) | "USD" |
order_id | Unique transaction ID | "ord_123abc" |
Event Metadata
Additional context about when and where the event occurred.
Field | Description |
---|---|
event_id | Unique ID to prevent duplicate events |
occurred_at | When the event occurred (ISO 8601, defaults to now) |
source_url | Page URL where event occurred |
Privacy & Consent
Field | Description |
---|---|
consent | User consent for advertising - set to false to prevent data from being sent to ad platforms |
Complete Example
Here's a complete example with all recommended fields:
const response = await fetch('https://api.channelstack.dev/v1/track', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
// Required
api_key: 'key_...',
event: 'purchase_completed',
// User identification
email: 'john.doe@example.com',
phone: '+15551234567',
distinct_id: 'user_123',
first_name: 'John',
last_name: 'Doe',
city: 'San Francisco',
state: 'CA',
zip: '94102',
country: 'US',
// Purchase data
value: 149.99,
currency: 'USD',
order_id: 'ord_abc123',
// Click IDs (if available)
gclid: 'CjwKCAjw...', // From URL parameter
fbc: '_fbc.1.1554...', // From cookie
fbp: '_fbp.1.1554...', // From cookie
// Event metadata
event_id: 'evt_unique123',
source_url: 'https://example.com/checkout',
// Privacy
consent: true,
// Any custom properties
product_category: 'electronics',
coupon_used: 'SAVE20'
}),
})
Privacy & Security
- All PII (email, phone, name, address) is automatically hashed with SHA-256 before sending to ad platforms
- Server automatically captures and anonymizes IP addresses from request headers for privacy compliance
- User agent and referrer are automatically captured from request headers (not sent in request body)
- Set
consent: false
to prevent data from being sent to ad platforms (GDPR compliance) - We never store raw PII - only hashed values
- All data transmission uses HTTPS encryption
Response Format
// Success response
{
"success": true,
"eventId": "evt_unique123",
"message": "Event recorded successfully"
}
// Error response
{
"error": "Invalid API key",
"code": 401
}