Build with EarlyCRO
Full API reference for integrating EarlyCRO into your applications. Build custom integrations, automate workflows, and access your data programmatically.
Quick Start
Authentication
EarlyCRO uses two types of authentication:
API Key (SDK endpoints)
Used for client-side SDK requests. Found in your project settings.
?key=YOUR_SDK_KEYJWT Token (Dashboard API)
Used for server-side requests. Obtained via /auth/token endpoint.
Authorization: Bearer YOUR_JWT_TOKENBase URLs
All API requests should be made to:
Production
https://api.earlycro.comSDK CDN
https://api.earlycro.com/sdk/v1JavaScript SDK
The EarlyCRO SDK provides a simple API for tracking events, identifying users, and getting experiment variations.
init(config)Initialize the SDK with your project configuration
CRO.init({
projectId: 'proj_xxx',
debug: false
});track(eventName, properties)Track a custom event for conversion goals
CRO.track('purchase', {
value: 99.99,
currency: 'USD',
productId: 'prod_123'
});identify(userId, traits)Identify a user for cross-session tracking
CRO.identify('user_456', {
email: 'user@example.com',
plan: 'premium'
});getVariation(experimentKey)Get the assigned variation for an experiment
const variant = CRO.getVariation('homepage-hero-test');
// Returns: 'control' | 'variant-a' | 'variant-b'setUserAttribute(key, value)Set custom attributes for targeting
CRO.setUserAttribute('isPremium', true);
CRO.setUserAttribute('country', 'US');REST API Endpoints
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /sdk/v1/config | Get experiment configuration for a project | API Key |
| POST | /sdk/v1/events | Send tracked events (pageviews, clicks, conversions) | API Key |
| POST | /sdk/v1/recordings/upload | Upload session recording chunks | API Key |
| GET | /api/v1/projects | List all projects in your organization | JWT |
| POST | /api/v1/projects | Create a new project | JWT |
| GET | /api/v1/projects/:id/experiments | List experiments for a project | JWT |
| POST | /api/v1/projects/:id/experiments | Create a new experiment | JWT |
| GET | /api/v1/experiments/:id/results | Get experiment results with Bayesian analysis | JWT |
| GET | /api/v1/projects/:id/heatmaps/:pageHash | Get heatmap data for a page | JWT |
| GET | /api/v1/projects/:id/recordings | List session recordings | JWT |
Example Requests
/api/v1/projects/:projectId/experimentsList all experiments for a project
curl -X GET "https://api.earlycro.com/api/v1/projects/proj_xxx/experiments" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json"
Response
{
"experiments": [
{
"id": "exp_123",
"name": "Homepage Hero Test",
"status": "running",
"variations": [
{ "id": "var_1", "name": "Control", "traffic": 50 },
{ "id": "var_2", "name": "Variant A", "traffic": 50 }
],
"created_at": "2024-12-01T00:00:00Z"
}
]
}/sdk/v1/eventsSend tracked events from the SDK
curl -X POST "https://api.earlycro.com/sdk/v1/events?key=YOUR_SDK_KEY" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"type": "pageview",
"url": "https://example.com/pricing",
"visitor_id": "vis_abc123",
"session_id": "ses_xyz789",
"timestamp": "2024-12-15T10:30:00Z"
},
{
"type": "conversion",
"goal_id": "goal_signup",
"visitor_id": "vis_abc123",
"timestamp": "2024-12-15T10:32:00Z"
}
]
}'/api/v1/experiments/:id/resultsGet experiment results with Bayesian analysis
curl -X GET "https://api.earlycro.com/api/v1/experiments/exp_123/results" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
Response
{
"experiment_id": "exp_123",
"total_visitors": 2500,
"total_conversions": 91,
"variations": [
{
"variation_id": "var_1",
"variation_name": "Control",
"visitors": 1247,
"conversions": 40,
"conversion_rate": 0.0321,
"probability_to_beat_control": 0,
"expected_lift": 0,
"credible_interval_low": 0.0231,
"credible_interval_high": 0.0429
},
{
"variation_id": "var_2",
"variation_name": "Variant A",
"visitors": 1253,
"conversions": 51,
"conversion_rate": 0.0407,
"probability_to_beat_control": 0.893,
"expected_lift": 0.268,
"credible_interval_low": 0.0304,
"credible_interval_high": 0.0527
}
]
}Need Help with Integration?
Our team is here to help you get set up. Reach out anytime.