API Documentation

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_KEY

JWT Token (Dashboard API)

Used for server-side requests. Obtained via /auth/token endpoint.

Authorization: Bearer YOUR_JWT_TOKEN

Base URLs

All API requests should be made to:

Production

https://api.earlycro.com

SDK CDN

https://api.earlycro.com/sdk/v1

JavaScript 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

MethodEndpointDescriptionAuth
GET/sdk/v1/configGet experiment configuration for a projectAPI Key
POST/sdk/v1/eventsSend tracked events (pageviews, clicks, conversions)API Key
POST/sdk/v1/recordings/uploadUpload session recording chunksAPI Key
GET/api/v1/projectsList all projects in your organizationJWT
POST/api/v1/projectsCreate a new projectJWT
GET/api/v1/projects/:id/experimentsList experiments for a projectJWT
POST/api/v1/projects/:id/experimentsCreate a new experimentJWT
GET/api/v1/experiments/:id/resultsGet experiment results with Bayesian analysisJWT
GET/api/v1/projects/:id/heatmaps/:pageHashGet heatmap data for a pageJWT
GET/api/v1/projects/:id/recordingsList session recordingsJWT

Example Requests

GET/api/v1/projects/:projectId/experiments

List 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"
    }
  ]
}
POST/sdk/v1/events

Send 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"
      }
    ]
  }'
GET/api/v1/experiments/:id/results

Get 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.