Identify and leads

A lead is a person linked to a session – the bridge between anonymous analytics and your CRM. 3x offers two ways to create leads, and both keep personal data minimal.

identify() in the browser

import { identify, getIds } from "@x3growth/sdk";

form.addEventListener("submit", async () => {
  await identify({
    email: form.email.value,
    firstName: form.firstName.value,
    form: "contact",
    traits: { plan: "pro", employees: "11_50" },
  });
});
  • E-mail, phone, first name, last name, external id and leadId are normalized and hashed with SHA-256 in the browser (WebCrypto). Only hashes travel; the API never sees plaintext from identify().
  • Phone numbers: digits with country code; 00 prefixes and (0) trunks are handled; national numbers get the project country's calling code, and are dropped when the project has no country.
  • E-mail: lowercased; an additional Google variant (dots removed for Gmail) is hashed for Google Ads.
  • traits: up to 20 non-personal attributes; values that look like e-mail addresses or phone numbers are dropped.
  • Sent only with consent unless the project sets tracking.identify.requireConsent = false (decide with your DPO).
  • One lead row per session and identity: calling identify() repeatedly updates the same row.

The session gets identified = true, goals of kind lead fire, the relevance model adds its identified points, and conversion definitions with a lead trigger record a conversion (subject to the web guards).

Lead mit Besuchen verknüpfen – in the dashboard the same as „Einem Lead zuordnen“ on a visit.

When your website knows who the visitor is – a customer logs into your portal, a newsletter link carries your contact id, your CRM opens a page for a known lead – attach the visit to that lead:

import { identify } from "@x3growth/sdk";

// your own id of a lead X3 already knows: CRM record id, your lead/customer id or the X3 lead id
await identify({ leadId: customer.crmId });

With the script tag: window.x3("identify", { leadId: customer.crmId }).

  • leadId is normalized like externalId (trimmed, at most 200 characters) and hashed with SHA-256 in the browser; X3 stores a keyed hash of it (per project), never the id.
  • It never creates a lead. X3 maps the id to an existing lead: its externalId (leads.create({ externalId })), its X3 lead id, or the record id of its CRM link (HubSpot, Pipedrive, …). An id that is not known yet waits on the visit; the moment a lead with that externalId is stored, the visit joins it.
  • The visit appears in the lead's Sitzungen with the evidence „Von der Website gemeldet“ (sdk_identify). With consent, the visitor id x3_vid links every earlier and later visit of the same browser to the lead too (visitor_id). Without consent only this visit – and visits with the same ad click id or on the same day – belong to the lead; nothing is stored in the browser.
  • It follows the same consent rule as every identify() call: by default (tracking.identify.requireConsent, dashboard „Nur mit Einwilligung verknüpfen“) it is only sent with consent. Switch the rule off only when your legal basis covers linking without consent (for example a logged-in customer area – decide with your DPO).
  • You may combine it with the other fields: identify({ email, leadId }) creates or updates the lead row of the e-mail as before and links the visit to the lead behind leadId.

Without the SDK call the dashboard links visits too: on a visit or recording, Einem Lead zuordnen suggests leads (same consented visitor, same ad click or day, a lead that came in shortly after the visit) or searches by name, e-mail, phone or inquiry number, and assigns the visit after a confirmation – with who and when, reversible with Zuordnung lösen. The same through the API and MCP:

EndpointScopePurpose
GET /v1/projects/{project}/leads/{id}/sessionsanalytics:read + leads:summaryevery visit of the lead with its evidence, first touch, visits, returns (no contact data)
POST /v1/projects/{project}/leads/{id}/sessionsleads:writeassign a visit by hand ({ sessionId })
POST /v1/projects/{project}/leads/{id}/sessions/unlinkleads:writeremove a visit from the lead ({ sessionId }; the inquiry visit itself cannot be removed)
GET /v1/projects/{project}/sessions/{sessionId}/lead-candidates?q=analytics:read + leads:readleads of the visit and suggestions (contact data)

MCP: leads_sessions, leads_session_candidates, leads_sessions_link, leads_sessions_unlink. How the evidence types work and what X3 does without consent: Customer journeys.

Leads from your server

When the form posts to your backend anyway, create the lead there with a secret key – this is the most robust path and the only one that can store plaintext:

import { createX3Server } from "@x3growth/sdk/server";

const x3 = createX3Server({ apiUrl: process.env.X3_API_URL!, apiKey: process.env.X3_SECRET_KEY! });

await x3.leads.create({
  sessionId,                      // from getIds() in the browser
  form: "contact",
  email, firstName, lastName, company,
  message,                        // stored only when the project stores plaintext
  answers: { "pricing-quiz": { team_size: "11_50" } },
  summary: "Pro plan, 11–50 seats, wants a demo",
  spam: honeypotFilled,           // spam leads are kept but excluded everywhere by default
  conversion: { definition: "lead", eventId },
});
FieldNotes
email, phone, firstName, lastName, externalIdalways hashed; plaintext e-mail, names, company and the phone (E.164, national numbers get the project country's calling code) kept only with settings.pii.storePlaintext. An invalid phone (fewer than 7 or more than 15 digits) never rejects the lead: it is stored without phone and flagged traits.phone_invalid (masked, e.g. 01•••12)
grade, scoreyour qualification; the dashboard and MCP show the grade as fit words (fit: A „Passt sehr gut“, B „gut“, C „mittel“, D „eher nicht“) with the answers that decided it
company, messageplaintext only with storePlaintext; message is never returned by MCP
answers{questionnaire: {question: option}}
score, grade, summaryyour qualification (see fit above)
spamhoneypot result; excluded from lists, MCP, goals, identified and lead triggers unless include_spam=true
attributionfor leads without a session
conversionalso record a conversion of this definition

Requires the scope leads:write. The request is idempotent with an Idempotency-Key header.

Reading and erasing leads

  • Dashboard Leads (members with the personal-data permission), CSV export.
  • GET /v1/projects/{project}/leads and /leads.csv (leads:read), MCP leads_list (never phone numbers or free text).
  • DELETE /v1/projects/{project}/leads/{id} erases a lead and the hashes on its conversions.
  • settings.pii.leadsRetentionDays deletes leads automatically after N days.