Events API
Track user actions and behaviors via the API.
Track Event
Records an event for a contact.
POST /api/v1/eventsRequest Body
externalId
string
Yes
The contact's external ID
eventKey
string
Yes
Unique identifier for the event type
properties
object
No
Additional event properties
Example Request
curl -X POST https://app.cueflow.so/api/v1/events \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"externalId": "user-123",
"eventKey": "purchase_completed",
"properties": {
"amount": 99.99,
"currency": "USD",
"plan": "pro",
"method": "credit_card"
}
}'Response
Status Codes
201
Event created
400
Invalid request body
401
Unauthorized
404
Contact not found
Event Keys
Event keys are unique identifiers for event types. Use consistent naming:
Naming Convention
Use snake_case for event keys:
Common Event Patterns
Onboarding
signup_completed, onboarding_started, onboarding_completed
Features
feature_used, report_created, export_completed
Commerce
purchase_completed, plan_upgraded, plan_downgraded
Engagement
page_viewed, button_clicked, form_submitted
Event Properties
Properties provide context about the event.
Supported Types
String
"plan": "enterprise"
Number
"amount": 99.99
Boolean
"isFirstPurchase": true
Example Properties
Using Events for Targeting
Events enable powerful behavioral targeting in your messages.
Event-Based Rules
After tracking events, you can target users based on:
Has done
User completed onboarding
Has not done
User hasn't used feature X
Count greater than
Power users (10+ exports)
First done within
Recently started using feature
Last done within
Active in last 7 days
Example: Feature Adoption Campaign
Then create a message targeting:
advanced_export_viewedhas doneadvanced_export_usedhas not done
Code Examples
Node.js
Python
PHP
API vs Embed Script
You can track events via the API or the embed script. Here's when to use each:
Server-side events
Client-side interactions
Webhook triggers
Button clicks, page views
Background jobs
User-initiated actions
Batch processing
Real-time tracking
API Example (Server-Side)
Embed Script Example (Client-Side)
Best Practices
Event Naming
Use descriptive, action-based names
Stick to
snake_caseconsistentlyGroup related events with prefixes:
onboarding_*,billing_*
Properties
Keep properties flat (avoid nested objects)
Use consistent property names across events
Include relevant context without over-tracking
Timing
Track events as close to the action as possible
Use server-side tracking for critical events (purchases, signups)
Use client-side tracking for UI interactions
Privacy
Don't include PII in event properties
Review what you're tracking for compliance
Consider data retention policies
Last updated