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>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
});identify() for custom websites.3Track Events
Fire Facebook standard events with full CAPI + browser pixel deduplication:
// 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
| Event Name | Description |
|---|---|
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 |
PurchaseCompleted purchase
InitiateCheckoutStarted checkout process
AddToCartAdded item to cart
AddPaymentInfoAdded payment information
LeadLead form submitted
CompleteRegistrationRegistration completed
ViewContentViewed a product or content
SearchPerformed a search
AddToWishlistAdded to wishlist
SubscribeSubscription started
StartTrialTrial started
ContactContact form submitted
ScheduleAppointment scheduled
SubmitApplicationApplication 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.
/v1/webhook/custom/YOUR_FUNNEL_ID
Send purchase or lead events from your server. Requires x-api-key header.
POST https://api.rapidmetrics.ai/v1/webhook/custom/YOUR_FUNNEL_ID
Content-Type: application/json
x-api-key: YOUR_API_KEYPurchase Event
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 -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
| Field | Type | Required | Description |
|---|---|---|---|
event | string | â | "purchase" or "lead" |
email | string | â | Valid email address |
amount | number | â (purchase) | Purchase amount (e.g. 49.99) |
currency | string | 3-letter code (default: "USD") | |
product_name | string | Product or plan name | |
first_name | string | Customer first name | |
last_name | string | Customer last name | |
phone | string | Phone number | |
order_id | string | Unique order ID for dedup | |
metadata | object | Any additional data (stored in logs) |
eventstring â
"purchase" or "lead"
emailstring â
Valid email address
amountnumber â
(purchase)Purchase amount (e.g. 49.99)
currencystring3-letter code (default: "USD")
product_namestringProduct or plan name
first_namestringCustomer first name
last_namestringCustomer last name
phonestringPhone number
order_idstringUnique order ID for dedup
metadataobjectAny additional data (stored in logs)
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
| Status | Meaning |
|---|---|
| 200 | Success |
| 400 | Invalid input (check error message) |
| 401 | Missing x-api-key header |
| 403 | Invalid API key |
| 404 | Funnel not found |
| 413 | Request body too large (max 10KB) |
