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
Hand this single file to Cursor, Claude, Copilot, or any AI coding assistant and ask it to integrate Leadara — it has the recommended setup, the SDK, the plugin, and the full API. The file is in English.
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 (any framework) → drop in the JavaScript snippet. Recommended for anything in a browser; it auto-tracks page views.
- 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
Everything below needs two values from your dashboard under Integrations → Sources (or the Install screen):
- Workspace ID — a UUID like
1c4f1e2a-…. - Write key — used in the snippet and the
x-write-keyheader. It's publishable (safe in client code) and can only write events.
Website 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." });Optional script attributes
| Attribute | Purpose |
|---|---|
data-session-replay="true" | Record masked session replays (cover in your privacy policy). Uploads over HTTP — separate from live delivery. |
data-replay-sample-rate="0.5" | Record a fraction of sessions (0–1) when replay is on. |
data-realtime="false" | Turn off the background live connection. Tracking and replay still work; instant popup push and live chat do not. |
data-debug="true" | Log install diagnostics to the browser console. |
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? Add
data-realtime="false"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.