RapidMetrics

Developers Documentation

Track sales, leads, and custom events from any website or application. RapidMetrics handles browser pixel firing and Facebook CAPI server-side events with automatic deduplication.


Quick Start

1Add the Tracking Script

Paste this in your page's <head>:

<script>
(function(w, f) {
    var q = [];
    w.RapidMetrics = {
        identify: function() { q.push(['identify', arguments]) },
        track:    function() { q.push(['track', arguments]) },
        _q: q
    };
    var s = document.createElement('script');
    s.src = 'https://api.rapidmetrics.ai/v1/session.js?fid=' + f;
    s.async = true;
    document.head.appendChild(s);
})(window, 'YOUR_FUNNEL_ID');
</script>
💡 Tip: Get your funnel ID from the RapidMetrics dashboard under Funnels → Setup. You can safely call identify() and track() immediately — they'll be queued until the script loads.

2Identify Visitors

Call identify() after a form submission, login, or any point where you know the visitor's email:

RapidMetrics.identify({
    email: '[email protected]',
    first_name: 'John',        // optional
    last_name: 'Doe',          // optional
    phone: '+1234567890',      // optional
    customer_id: 'cust_123'    // optional
});
â„šī¸ Note: If you're using GoHighLevel, ClickFunnels, or Systeme.io, identification happens automatically. You only need identify() for custom websites.

3Track Events

Fire Facebook standard events with full CAPI + browser pixel deduplication:

Examples
// Initiate Checkout
RapidMetrics.track('InitiateCheckout', {
    value: 49.99,
    currency: 'USD',
    content_name: 'Premium Plan'
});

// Purchase
RapidMetrics.track('Purchase', {
    value: 49.99,
    currency: 'USD',
    content_name: 'Premium Plan'
});

// Lead (no value needed)
RapidMetrics.track('Lead');

// Add to Cart
RapidMetrics.track('AddToCart', {
    value: 29.99,
    currency: 'USD',
    content_name: 'Starter Plan'
});

Both identify() and track() return Promises:

RapidMetrics.track('Purchase', { value: 99 })
    .then(function(res) {
        console.log('Tracked:', res.event_ids);
    });

Supported Events

Purchase

Completed purchase

InitiateCheckout

Started checkout process

AddToCart

Added item to cart

AddPaymentInfo

Added payment information

Lead

Lead form submitted

CompleteRegistration

Registration completed

ViewContent

Viewed a product or content

Search

Performed a search

AddToWishlist

Added to wishlist

Subscribe

Subscription started

StartTrial

Trial started

Contact

Contact form submitted

Schedule

Appointment scheduled

SubmitApplication

Application submitted


Server-Side Webhook

For server-to-server integrations, send purchase and lead events directly via HTTP. Use this from your backend, Zapier, Make, or any automation tool.

Server-side only

Never expose your API key in client-side code (browser, frontend). This endpoint must only be called from a server, backend function, or automation platform (Zapier, Make, etc.).

Where to find your API key

Go to Dashboard → Integrations → Custom / API → Setup to reveal and copy your workspace API key.

POST

/v1/webhook/custom/YOUR_FUNNEL_ID

Send purchase or lead events from your server. Requires x-api-key header.

Base URL
POST https://api.rapidmetrics.ai/v1/webhook/custom/YOUR_FUNNEL_ID
Content-Type: application/json
x-api-key: YOUR_API_KEY

Purchase Event

cURL Example
curl -X POST https://api.rapidmetrics.ai/v1/webhook/custom/YOUR_FUNNEL_ID \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "event": "purchase",
    "email": "[email protected]",
    "amount": 49.99,
    "currency": "USD",
    "product_name": "Premium Plan",
    "first_name": "John",
    "last_name": "Doe",
    "order_id": "ORD-123"
  }'

Lead Event

cURL Example
curl -X POST https://api.rapidmetrics.ai/v1/webhook/custom/YOUR_FUNNEL_ID \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "event": "lead",
    "email": "[email protected]",
    "first_name": "Jane",
    "last_name": "Smith"
  }'

Request Body

eventstring ✅

"purchase" or "lead"

emailstring ✅

Valid email address

amountnumber ✅ (purchase)

Purchase amount (e.g. 49.99)

currencystring

3-letter code (default: "USD")

product_namestring

Product or plan name

first_namestring

Customer first name

last_namestring

Customer last name

phonestring

Phone number

order_idstring

Unique order ID for dedup

metadataobject

Any additional data (stored in logs)

Response

Success Response
{
    "status": "success",
    "event": "purchase",
    "order_id": "ORD-123",
    "purchases_created": 1,
    "pixel_events_queued": 2
}

Deduplication

If you provide order_id, the same order won't be processed twice. Without order_id, each request is treated as a new event.

Error Codes

StatusMeaning
200Success
400Invalid input (check error message)
401Missing x-api-key header
403Invalid API key
404Funnel not found
413Request body too large (max 10KB)