Documentation Index
Fetch the complete documentation index at: https://docs.datalyr.com/llms.txt
Use this file to discover all available pages before exploring further.
Stripe Webhooks
Connect Stripe webhooks to automatically track purchases and subscriptions as conversion events. DATALYR matches customers to their original ad click using email-based identity resolution.What You’ll Learn
- How to configure Stripe webhooks
- Supported Stripe events
- Email attribution matching
- Testing and verification
Before You Start
- DATALYR tracking script installed on your website
- Email capture with
datalyr.identify({ email })before checkout - Admin access to Stripe Dashboard
- Active workspace in DATALYR
Supported Events
DATALYR processes these Stripe webhook events:| Stripe Event | DATALYR Event | Description |
|---|---|---|
checkout.session.completed | purchase | One-time payment completed |
customer.subscription.created | subscribe | New subscription started |
invoice.payment_succeeded | purchase | Recurring subscription payment |
How Attribution Works
When a customer completes a Stripe checkout:- Stripe sends webhook with
customer_emailto DATALYR - DATALYR queries events table: “Find visitor_id where email matches”
- DATALYR retrieves original attribution (fbclid, gclid, UTMs)
- Event is created with
source: 'stripe'and attribution data - Conversion rules fire postbacks to Meta, Google, TikTok
Attribution only works if you call
datalyr.identify({ email }) before the customer reaches Stripe checkout. The email must be captured in a DATALYR event first.Step 1: Get Webhook URL
- Log in to DATALYR dashboard
- Navigate to Sources tab
- Click Webhooks tab
- Click Stripe card
- Copy your webhook URL
Step 2: Configure Stripe Webhook
Add Webhook Endpoint
- Log in to Stripe Dashboard
- Navigate to Developers → Webhooks
- Click Add endpoint
- Paste your DATALYR webhook URL
- Click Select events
Select Events
Choose these events to listen to:checkout.session.completedcustomer.subscription.createdinvoice.payment_succeeded(optional, for recurring payments)
Get Signing Secret
After creating the webhook:- Click on the webhook endpoint
- Click Reveal next to Signing secret
- Copy the secret (starts with
whsec_) - Return to DATALYR webhook setup modal
- Paste the signing secret
- Click Save
Step 3: Verify Setup
Test with Stripe CLI
If you have Stripe CLI installed:Test with Real Checkout
- Create a test product in Stripe
- Visit your site with ad parameters:
yoursite.com?fbclid=test123 - Call
datalyr.identify({ email: '[email protected]' }) - Complete Stripe checkout with the same email
- Check DATALYR Event Stream
- A
purchaseevent withsource: 'stripe' - Attribution data (fbclid, visitor_id) from original session
- Event value matching Stripe amount
Step 4: Create Conversion Rules
After verifying webhook events are created, set up conversion rules to fire events to ad platforms.Example: Meta Purchase Event
- Navigate to Integrations → Conversion Rules
- Click Create Rule
- Configure rule:
- Event Name:
purchase - Event Source:
stripe
- Platform: Meta Ads
- Event Type:
Purchase
- Use event value from webhook
Event Data Structure
Stripe webhooks create events with this structure:Attribution Match Rate
DATALYR’s email-based attribution achieves:- 95%+ match rate when email is captured before checkout
- 90%+ match rate for cross-device (mobile ad → desktop purchase)
- 85%+ match rate for 30+ day attribution windows
Maximize Match Rate
Capture email early in the customer journey:Value Calculation
DATALYR automatically converts Stripe amounts:- Checkout sessions:
amount_total / 100(Stripe uses cents) - Subscriptions: Monthly value calculated from billing interval
- Annual:
amount / 100 / 12 - Monthly:
amount / 100 - One-time:
amount / 100
- Annual:
Deduplication
Stripe may send the same webhook multiple times (retries). DATALYR uses Cloudflare KV to deduplicate:- Extract
event.idfrom webhook - Check if
workspace_id:event_idexists in KV - If exists, return 200 OK but skip processing
- If new, process and store in KV
Security
DATALYR verifies all Stripe webhooks using signature validation:- Extract
Stripe-Signatureheader - Verify signature matches webhook secret
- Reject invalid signatures with 401 Unauthorized
Troubleshooting
Events have no attribution data
Symptoms: Stripe events appear in Event Stream but fbclid/gclid are null Cause: Email was not captured withdatalyr.identify() before checkout
Solution:
- Add
datalyr.identify({ email })on email capture forms - Ensure identify call happens before Stripe checkout redirect
- Test by checking Event Stream for identify events with the same visitor_id
Webhooks not appearing in Event Stream
Symptoms: Stripe checkout completes but no event in DATALYR Cause: Webhook URL not configured or signing secret incorrect Solution:- Check Stripe Dashboard → Webhooks → verify endpoint is active
- Click webhook endpoint → check for delivery errors
- Verify signing secret in DATALYR matches Stripe
- Test with Stripe CLI to see error details
Signature verification failed
Symptoms: Stripe Dashboard shows webhook delivery failures with 401 errors Cause: Signing secret mismatch or not saved in DATALYR Solution:- Get signing secret from Stripe webhook endpoint
- Return to DATALYR webhook setup modal
- Paste and save the signing secret
- Trigger new test event
Wrong event value
Symptoms: Event value in DATALYR doesn’t match Stripe amount Cause: Currency conversion or subscription interval calculation Solution:- Check
event_data.amount_totalin Event Stream - Verify currency is correct (DATALYR uses uppercase)
- For subscriptions, check billing interval in
event_data.interval - Contact support if amounts are incorrect
What Happens Next
After webhook events are created:- Postback Worker checks for matching conversion rules
- Rules filtered by
trigger_event_source: 'stripe' - Conversions fire to Meta, Google, TikTok with original attribution
- Ad platforms receive events with fbclid/gclid for optimization
Stripe Revenue Analytics (Separate Feature)
Webhook attribution is separate from Stripe Revenue Analytics: Webhooks (This Feature):- Real-time conversion tracking
- Fires events to ad platforms
- No OAuth required
- Dashboard metrics (MRR, ARR, churn)
- Requires API key connection
- Periodic data sync