Skip to main content
Timeline: 30-60 minutes Common for: Subscription companies using Stripe’s hosted checkout page

The challenge

Click IDs (gclid, fbclid) get lost when customers redirect to Stripe’s hosted checkout. When they complete purchase and return to your site, you can’t connect the conversion to the original campaign. Result: Conversions show as “direct” in GA4. Marketing can’t prove ROI. Google Ads can’t optimise for users who actually subscribe.

How Fidero solves this

Browser State Capture preserves click IDs before redirect. When the purchase event arrives via webhook, our server enriches it with persisted attribution automatically.

Implementation

1

Install pixel on marketing site

<script>
  fidero.load()
  fidero.init("YOUR_PROJECT_ID")
  fidero.page() // Captures gclid, fbclid, UTMs immediately
</script>
Our pixel automatically captures and persists gclid, fbclid, UTMs and referrer data.
2

Track checkout_started before redirect

// Before redirecting to Stripe
fidero.track({
  event: "checkout_started",
  properties: {
    value: 29.99,
    currency: "GBP",
    items: [{
      item_id: "premium_plan",
      item_name: "Premium Monthly",
      price: 29.99,
      quantity: 1,
    }],
  },
})

// Then redirect to Stripe
window.location.href = stripeCheckoutUrl
3

Track subscription_started from webhook

// Server-side webhook handler (runs when Stripe confirms payment)
await fetch("https://api.fidero.com/v1/track", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${FIDERO_API_KEY}`,
  },
  body: JSON.stringify({
    projectId: "YOUR_PROJECT_ID",
    userId: customer.id, // CRITICAL: Must match user who started checkout
    event: "subscription_started",
    properties: {
      transaction_id: session.id, // CRITICAL: Enables 98% deduplication
      value: session.amount_total / 100,
      currency: session.currency,
      subscription_id: subscription.id,
    },
    timestamp: new Date().toISOString(),
  }),
})
The userId must match the user who started checkout. This connects the server-side conversion to the browser-side session, pulling in preserved attribution.
4

Verify attribution preservation

Check your dashboard. The subscription_started event should include:
  • Original click IDs (gclid, fbclid)
  • First touch attribution from initial ad click
  • Last touch attribution from recent session
  • All UTM parameters
Our server enriches webhook events with the preserved user profile automatically.

What you’ll see

Within 24 hours: Attribution recovery starts. Conversions that previously showed as “direct” now include campaign context. Within a week: GA4↔Meta↔Google Ads show consistent conversion numbers. Marketing can prove ROI on 85%+ of conversions instead of guessing on 30%+. Typical results: 20-40% conversion recovery for B2C subscription companies. Google Ads learns which users actually subscribe (not just click). Meta’s algorithm optimises for real conversions with complete context.
The technical flow:
  1. User clicks Google Ad with gclid=abc123 → lands on your site
  2. Pixel captures gclid=abc123 → sends to Fidero server → persists in user profile
  3. User starts checkout → redirects to Stripe (gclid lost in URL)
  4. User completes payment → Stripe webhook fires
  5. Your server sends conversion event with userId → Fidero server looks up user profile → enriches event with gclid=abc123 → sends to Google Ads
Google Ads receives conversion with original click ID intact. Attribution preserved across redirect.
Same pattern works for any hosted checkout flow:
// Before redirect to hosted checkout
fidero.track({
  event: "checkout_started",
  properties: { value: 29.99, currency: "GBP" }
})

// Server-side when payment confirmed
await fetch("https://api.fidero.com/v1/track", {
  method: "POST",
  body: JSON.stringify({
    userId: customer.id,
    event: "subscription_started",
    properties: { transaction_id: payment.id, value: 29.99 }
  })
})
Attribution context preserved regardless of which payment provider you use.

Next steps