Back to guides

B2B and lead gen

Track every lead through to revenue

Last updated 2026-05-13

Connect the first ad click to the form, booked call, closed deal, and payment. You will see which campaigns create revenue, not just cheap leads.

Quick start guides: JavaScript / HTML · React / Next.js

1

Create your DATALYR account

  1. Sign up at datalyr.com/signup
  2. Go to Settings → API — copy your API key (starts with dk_)
2

Install the Web SDK

The Web SDK tracks visitors across your landing pages, funnels, and website so we can connect every lead back to the exact ad that brought them in.

  1. HTML: follow the setup guide
  2. React / Next.js: follow the setup guide

Install the SDK on every page in your funnel — landing pages, thank you pages, booking pages, and your main site. This is what lets DATALYR stitch the full journey together.

3

Track lead events

Track key events in your funnel so DATALYR knows when a visitor becomes a lead and when that lead becomes a customer.

Common events to track:

  • Form submission (lead captured)
  • Call booked / appointment scheduled
  • Application submitted
  • Call completed / show rate
  • Proposal sent
  • Deal closed / payment received

Use the SDK’s track() method to fire these events at each stage. The more steps you track, the better you can see where leads drop off and which ad sources produce the best leads.

4

Identify your leads

Call identify()with the lead’s email as soon as you capture it (form submit, booking, etc.). This is how DATALYR connects an anonymous ad click to a real person in your pipeline.

  • Call identify() on form submission, booking confirmation, or any point you capture an email
  • Pass the email at minimum
  • If you have a CRM ID or phone number, pass those too
5

Connect your revenue source

Connect your payment or CRM system to DATALYR so we can track when leads actually close and how much they pay.

  1. Stripe: Go to Sources → Stripe → Connect and authorize your Stripe account. No manual webhooks needed — revenue data flows automatically. Stripe setup reference →
  2. Whop: Go to Whop → Developer → API Keys and create a restricted Account API key. Grant company read, webhook management, and webhook receive permissions. Then open Sources in DATALYR. Find Whop, then select connect. Enter the API key and the biz_ company ID. DATALYR creates the signed webhook and managed Whop Pixel. Read the Whop setup reference. Auto identity can link the payment when the buyer uses the same email on your site and at Whop.
  3. API / Webhooks: Send events via the DATALYR API — use this if you track deals in a CRM like GoHighLevel, HubSpot, or Close and want to send deal_closed events with revenue values when deals are won.

Connect the system that records the payment. Use one revenue source for each transaction.

6

Connect your ad platforms

Connect your ad platforms so DATALYR can match ad spend to revenue and give you accurate ROAS, and we can send conversion events back server-side.

  1. Meta (Facebook / Instagram)
  2. Google Ads
  3. TikTok
  4. Other: reach out at hello@datalyr.com
7

Set up conversion rules

Configure conversion rules to send the right events back to your ad platforms so they can optimize for your highest-value leads — not just form fills, but actual closed deals.

  • Go to Conversions → Add Rule
  • Pick your trigger event (e.g. deal_closed, payment_received), choose your ad platform, and set the conversion value
  • Hit Save — it’s live immediately

Conversion rules reference →

8

Verify it's working

  • Set debug: true in the SDK — you should see events logging in your console
  • Submit a test lead through your funnel
  • Open Live in your dashboard — events should appear within seconds
  • Manually fire a deal_closed event via the API and confirm it shows up

Best practices

  • Optimize your ad platforms for downstream events, not just leads. Sending deal_closed or payment_receivedas your primary conversion gives ad platforms much better signal than optimizing for form fills. This is the biggest advantage of using DATALYR — you’re feeding real revenue data back to the algorithms.
  • Track every stage of your pipeline through the SDK or API: lead captured, call booked, call completed, proposal sent, deal closed. This lets you see exactly where each ad source’s leads fall off.
  • Always call identify() the moment you capture an email — this is the single most important thing for accurate attribution in lead gen.
  • If you have a long sales cycle, use the API to send deal events when they close (days or weeks later). DATALYR will still attribute the revenue back to the original ad click.
  • Don’t count leads as revenue. A form fill is not a sale. Track actual payments and closed deals as your revenue events — this is the only way to get real ROAS.

Why this matters for lead gen

The problem with most ad tracking for lead gen businesses:

  • Ad platform says you got 50 leads at $20 each — looks great
  • But only 10 of those leads showed up to a call
  • Only 3 closed, and 2 of those came from one campaign
  • The campaign that “looked expensive” per lead actually produced all your revenue

DATALYR fixes this by tracking the full journey from click to closed deal. You stop optimizing for cheap leads and start optimizing for actual revenue. Your ad platforms get better signal, your targeting improves, and your cost per acquisition drops — because you’re measuring what actually matters.

Turn every paid click into profitable growth