API Documentation

Integrate Lanorx into your applications using our JavaScript SDK or REST API.

Lanorx SDK

Recommended

Installation

npm

npm install @lanorx/tracking

yarn

yarn add @lanorx/tracking

pnpm

pnpm add @lanorx/tracking

Automatic Features:

  • Device ID tracking with 30-minute TTL (localStorage)
  • Device type detection (mobile, tablet, desktop)
  • Referrer tracking (document.referrer)
  • User agent collection (navigator.userAgent)
  • Page view tracking on initialization
  • CONVERSION event creation on email submission
  • Email duplicate check (use hasSubmittedEmail())

Select Your Stack

Integration Example

import { LanorxClient } from '@lanorx/tracking';
import type { ApiResponse, EmailSubmitResponse } from '@lanorx/tracking';

const client: LanorxClient = new LanorxClient({
  projectId: 'your_project_id',
  apiKey: 'your_api_key'
});

// Check if user has already submitted an email
const status: { submitted: boolean; email?: string } = client.hasSubmittedEmail();
if (status.submitted) {
  console.log('Email already submitted:', status.email);
}

// Submit an email (deviceId automatically managed)
// CONVERSION event is automatically created on server
const result: ApiResponse<EmailSubmitResponse> = await client.submitEmail({
  email: 'user@example.com'
});

if (result.success) {
  console.log('Submitted:', result.data!.email);
}

// Track CTA click
await client.trackCTA('hero');  // section: 'header', 'hero', 'pricing', 'features', etc.

Success Response

{
  "success": true,
  "data": {
    "id": "email_abc123",
    "email": "user@example.com",
    "createdAt": "2025-01-20T10:30:00.000Z"
  }
}

Error Responses

Invalid email format

{
  "error": "Validation error",
  "details": [
    {
      "code": "invalid_string",
      "message": "Invalid email format"
    }
  ]
}

Project not found

{
  "error": "Project not found"
}

Email limit reached

{
  "error": "Email collection limit reached for this month"
}

Get your API key from Settings → API Keys

REST API

Advanced

Authentication

All API requests require a valid API key in the Authorization header.

Authorization: Bearer lnx_sk_your_api_key
POST/api/v1/projects/{projectId}/emails

Request Body

email (required): Email address
deviceId (optional): Device identifier
deviceType (optional): Device type (mobile, tablet, desktop)
referrer (optional): Referrer URL
userAgent (optional): User agent string

Example

curl -X POST https://www.lanorx.com/api/v1/projects/proj_123/emails \
  -H "Authorization: Bearer lnx_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "deviceId": "lanorx_abc123",
    "deviceType": "desktop",
    "referrer": "https://google.com",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"
  }'
POST/api/v1/projects/{projectId}/events

Request Body

type (required): Event type (VIEW, CTA, SUBMIT, CONVERSION, NAVIGATE)
contentId (optional): A/B Testing variant ID
deviceId (optional): Device identifier
deviceType (optional): Device type (mobile, tablet, desktop)
referrer (optional): Referrer URL
userAgent (optional): User agent string
meta (optional): Additional metadata

Examples

# Track page view
curl -X POST https://www.lanorx.com/api/v1/projects/proj_123/events \
  -H "Authorization: Bearer lnx_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "type": "VIEW",
    "deviceId": "lanorx_abc123",
    "deviceType": "desktop",
    "referrer": "https://google.com",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"
  }'

# Track CTA click
curl -X POST https://www.lanorx.com/api/v1/projects/proj_123/events \
  -H "Authorization: Bearer lnx_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "type": "CTA",
    "deviceId": "lanorx_abc123",
    "deviceType": "mobile",
    "referrer": "https://twitter.com",
    "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)",
    "meta": {"section": "hero"}
  }'

# Track submit
curl -X POST https://www.lanorx.com/api/v1/projects/proj_123/events \
  -H "Authorization: Bearer lnx_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "type": "SUBMIT",
    "deviceId": "lanorx_abc123",
    "deviceType": "tablet",
    "referrer": "https://facebook.com",
    "userAgent": "Mozilla/5.0 (iPad; CPU OS 14_0 like Mac OS X)"
  }'

API Access

PlanAPI Access
FREENot available
STARTERNot available
PROUnlimited
ENTERPRISEUnlimited

No rate limits for PRO and ENTERPRISE plans.

Need Help?

Questions about integration? We are here to help.