ingestion
Send data in
The tracker snippet covers pageviews and events automatically. These endpoints let your backend push payments, tie a session to a known user, and shorten links.
/api/v1/payment| Param | Type | Description |
|---|---|---|
| amountreq | number | Amount (negative or refund:true for a refund). |
| currencyreq | string | ISO currency, e.g. USD. |
| transaction_idreq | string | Your id, used for dedup. |
| ref | string | window.datalenk.ref captured on your site. |
| string | Customer email, hashed server-side for attribution. | |
| refund | boolean | Mark this as a refund. |
curl -X POST https://datalenk.com/api/v1/payment \
-H "Authorization: Bearer dlk_…" -H "Content-Type: application/json" \
-d '{ "amount": 29.99, "currency": "USD", "transaction_id": "txn_98hj", "ref": "…" }'/api/v1/identify/api/v1/links/api/eventThe server beacon (AI crawlers)
AI crawlers do not run JavaScript, so no client-side script can ever see them, ours included. To get AI visibility (who crawls you, who cites you, and what that turns into), send one call per request from your middleware or edge function. We identify the crawler, and we verify it against published IP ranges and reverse DNS, so a spoofed user-agent cannot pollute your numbers.
/api/serverexport function middleware(req: Request) {
// fire and forget, never block the response
fetch("https://datalenk.com/api/server", {
method: "POST",
headers: { "Authorization": "Bearer dlk_…", "Content-Type": "application/json" },
body: JSON.stringify({
site_id: 42,
ua: req.headers.get("user-agent") ?? "",
ip: req.headers.get("cf-connecting-ip") ?? req.headers.get("x-forwarded-for") ?? "",
path: new URL(req.url).pathname,
}),
}).catch(() => {});
return;
}/payment, /identify, /links) authenticate with your workspace token (Dashboard, API, starts with dlk_), not with a scoped API key. The scoped keys (dlk_live_…) are for the read and export endpoints.The tracker
Every site needs the snippet once, on all pages. Creating a site returns it — including your site's data-key.
<script defer data-site="42" data-key="dk_..." src="https://in.datalenk.com/dl.js"></script>
By default the tracker is cookieless: it writes nothing to visitors' devices (no cookies, no localStorage) — no consent banner needed. Optional attributes:
data-persist— enables the Persistent layer (returning visitors, cohorts, multi-day attribution) by storing a first-party pseudonymous id (localStorage +datalenk_refcookie). Enable it from Settings → Tracking depth first: it walks you through the privacy-policy/consent implications.data-no-cookie— withdata-persist, keeps the id in localStorage only (no cookie).data-key— your site's public ingestion key (anti-spoofing). Shown in Settings → Install.