Integrate Leadara
Connect your site, app, or backend to Leadara. Grab the one-file guide for your AI coding tool, or follow the recommended path by hand.
Leadara works by receiving events (what people do) and identities (who they are). Once events flow in, the marketing team builds analytics, segments, journeys, and campaigns on top — you just need to send good events.
For your AI coding tool
Give your AI coding assistant this stable URL. The versioned English guide covers automatic Site Runtime, explicit SDK tracking, API-only, hybrid and WordPress integrations. The URL always points to the latest revision.
Stable, versioned guide for AI agents
Give your coding assistant this fixed URL. It always serves the current guide. The JSON manifest provides its version, SHA-256, supported modes and immutable revision links. Guide revisions and script releases are separate; verify the Runtime endpoints before installing.
For automatic browser discovery, choose Integrations → Site Runtime and install its one script. For explicit tracking choose the classic SDK below. For no browser script, choose API-only; for browser discovery plus authoritative server conversions, choose hybrid. Never install Runtime and classic SDK tags together.
Runtime 0.3.0 uses this public tag. Replace site_x with the complete site ID from your workspace's single SiteConnection:
<script defer src="https://api.leadara.ir/site-runtime.js" data-site-id="site_x"></script>Runtime uses independent session tokens; put no workspace ID, write key or API-base attribute on this tag. The API origin comes from src. Configure the exact website origin; origin matching is not domain ownership verification. Guide 3.0.0 (2026-10-18) documents the contract and capability limits.
Which path should I use?
Pick the first one that matches you:
- WordPress site → install the Leadara plugin, paste your Workspace ID and write key. No code.
- Website or web app → choose Site Runtime above for automatic discovery, or the classic SDK below for explicit tracking and SDK experiences.
- Mobile, backend, or server-side → call the HTTP API directly.
You can mix them — e.g. the snippet on your site plus the API from your server.
Get your credentials
The classic SDK, WordPress and HTTP API sections below use source credentials from Integrations → Sources. Runtime uses its site ID instead:
- Workspace ID — a UUID like
1c4f1e2a-…. - Write key — used in the classic SDK snippet and
x-write-keyheader. Browser keys are public; use a dedicated least-privilege Write source. Source keys may have other permissions.
Classic Website SDK snippet
Add this to your <head> and replace the two placeholders:
<script
async
src="https://api.leadara.ir/sdk/WORKSPACE_ID/sdk.js"
data-write-key="WRITE_KEY"
></script>It starts tracking page views automatically. Then call these anywhere:
window.leadara.identify("user-123", { email: "sam@example.com", plan: "pro" });
window.leadara.track("checkout_started", { cartValue: 149000, currency: "IRR" });
window.leadara.page("Pricing");
window.leadara.group("acct-42", { companyName: "Acme Co." });
window.leadara.reset(); // on logoutCall reset() when someone logs out, so the next person on the same device starts as a new visitor instead of being merged into the previous profile.
If your app calls these before the snippet has loaded (common in single-page apps), put this line above the snippet. Early calls are then kept and sent once it loads:
<script>window.leadara=window.leadara||{_q:[]};["identify","track","page","group","reset"].forEach(function(m){window.leadara[m]=window.leadara[m]||function(){window.leadara._q.push([m,[].slice.call(arguments)])}});</script>Website settings live in the dashboard
The snippet stays the same no matter which features you use. Turn features on and off from the dashboard. Changes reach your site within a few minutes, without editing your site code:
| Setting | Where | What it does |
|---|---|---|
| Session replay | Analytics → Session replay → Recording settings (also linked from Integrations → Website SDK) | Records masked visits. You also choose the share of visits, privacy masking and pages to skip. Cover it in your privacy policy. |
| Live connection | Integrations → Website SDK | Needed for instant popups and live chat. Tracking and replay work without it. |
| Ask for notifications after sign-in | Integrations → Website SDK | Asks signed-in visitors for push permission as soon as your site identifies them. |
Older attributes such as data-session-replay, data-replay-sample-rate, data-realtime and data-auto-subscribe-push are ignored now, so you can leave them on the tag or remove them.
The only optional attribute left is data-debug="true", which logs install diagnostics to the browser console while you troubleshoot.
Integration tips
- Load the snippet once — a single async tag in
<head>. Do not inject it on every route. - Do not call
window.leadara.init()when the script tag is already on the page — the SDK starts automatically. A manualinit()can open a duplicate live connection. - You only need
identify,track,group, andpage— no custom live connection or navigation handlers on your side. - Analytics-only? Turn off Live connection in Integrations → Website SDK if you do not use live popups or chat but still want events (and optional replay).
HTTP API
Send the write key in the x-write-key header on every request to https://api.leadara.ir.
curl -X POST 'https://api.leadara.ir/track' \
-H 'x-write-key: WRITE_KEY' \
-H 'Content-Type: application/json' \
-d '{"userId":"user-123","name":"purchase_completed","properties":{"total":249000}}'Endpoints: POST /track, /page, /screen, /identify, /group, /alias, and /batch (up to 100 events at once). Every event needs a userId and/or anonymousId. Responses use { "success": true, "data": … } — branch on success before reading data.
The downloadable guide above has the full request shapes, error codes, batching, and recommended event names — that's the version to hand to your AI coding assistant.
Tips
- Call
identifybeforelogged_inon the same page load, and includeemailand/orphoneso email/SMS journeys can reach them.trackdoes not carry traits — the journey reads the profile, not the login event. - On app boot, if a session already exists, call
identifywith traits from your user database (not only on fresh sign-in). Returning users often skip the login screen. - Stable, snake_case event names (
signed_up,purchase_completed) with details inproperties. Automations match the name exactly (case-sensitive). - Send a numeric value on your key conversion (e.g.
total) so revenue analytics work out of the box. - On the web, prefer the snippet — it handles anonymous visitors, sessions, and retries for you.
See the downloadable AI integration guide for full auth examples, session restore, and SMS/email prerequisites.