Skip to main content

Stripe

TraceLog tracks Stripe conversions via the Server-Side Events webhook API. There is no direct Stripe integration to configure -- instead, your backend receives Stripe webhooks and forwards the relevant data to TraceLog.

How It Works

Customer pays via Stripe checkout
|
Stripe sends webhook to your backend
|
Your backend sends event to TraceLog S2S API
|
Purchase appears in your TraceLog dashboard

Prerequisites

  • A TraceLog API key (found in Project Settings in the TraceLog dashboard)
  • A Stripe webhook already configured in your backend

Setup

In your Stripe webhook handler, when you receive a successful payment event (e.g., checkout.session.completed or payment_intent.succeeded), send a POST request to TraceLog:

curl -X POST https://api.tracelog.io/webhooks/events \
-H "Content-Type: application/json" \
-H "x-api-key: your-project-api-key" \
-d '{
"event_id": "pi_3abc123",
"event_name": "purchase",
"timestamp": "2026-03-15T10:30:00Z",
"customer_id": "cus_xyz",
"session_id": "tl_sess_abc123",
"metadata": {
"amount": 49.99,
"currency": "USD",
"items": [{ "name": "Pro Plan", "quantity": 1 }]
}
}'
FieldDescription
event_idUse Stripe's payment intent ID or checkout session ID as a natural idempotency key
event_nameThe event name (purchase, subscription_created, etc.)
timestampISO 8601 timestamp of the payment
customer_idYour Stripe customer ID or internal user ID
session_idTraceLog browser session ID (see Session Linking below)
metadataArbitrary payload -- amount, currency, items, plan name, etc.

Session Linking

To link purchases to browsing sessions (enabling conversion rate by source, revenue by channel, and buyer segments), pass the TraceLog session ID from the browser to your backend during checkout.

On the client side, capture the session ID before redirecting to Stripe:

const sessionId = tracelog.getSessionId();
// Pass sessionId to your backend (e.g., as a field in the checkout request)

On the server side, include the session_id field in the event payload sent to TraceLog.

info

When session_id is provided, the event is linked to the browser session for attribution. Without it, TraceLog creates a synthetic session for the event. You can still provide referrer and utm fields for attribution when no session ID is available.

Revenue Tracking Configuration

In the TraceLog dashboard, go to Project Settings > Revenue Tracking and configure:

  • Event name: purchase
  • Value source: Event field > amount

This tells TraceLog which field in the event metadata contains the monetary value.

Tracking Subscriptions

tip

Beyond one-time purchases, you can track the full subscription lifecycle by sending different event names for each stage:

  • subscription_created -- new subscription started
  • subscription_renewed -- recurring payment processed
  • subscription_cancelled -- customer cancelled

Each event type can be classified independently in the Event Catalog (e.g., mark subscription_created as a Conversion and subscription_cancelled as a Goal for churn tracking).

Idempotency

Duplicate event_id values return { "processed": false } and are not stored again. Use Stripe's own identifiers (payment intent ID, invoice ID, subscription ID) as event IDs to guarantee natural deduplication across webhook retries.

Rate Limits

The server-side events endpoint allows 100 requests per 60 seconds per API key. For high-volume stores, batch your webhook processing or implement a queue in your backend.