Stripe Checkout API

Step 1: Connect Stripe to Humblytics

Before you can track revenue with Stripe Checkout API, you need to connect your Stripe account to Humblytics:

  1. Go to your Humblytics dashboard and navigate to Site Settings

  2. Click on the Revenue tab to access revenue tracking settings

  3. Select Stripe as your payment provider

  4. Choose "Stripe API" as your integration method

  5. Enter your Stripe Secret Key (found in your Stripe Dashboard)

  6. Save the configuration to connect your Stripe account

Your Stripe Secret Key will be encrypted and stored securely. Never share your secret key publicly.

Step 2: Implement Checkout with Metadata

Once your Stripe account is connected, pass metadata with humblytics_view_id when creating a checkout session. You'll need to get the view ID from the frontend and pass it to your API endpoint:

// Frontend - get the view ID from Humblytics
const viewId = window.Humblytics.viewId;

// Send to your API endpoint
const response = await fetch('/api/create-checkout', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    line_items: [...],
    humblytics_view_id: viewId
  })
});
// app/api/create-checkout/route.js
export async function POST(request) {
  const { line_items, humblytics_view_id } = await request.json();

  const session = await stripe.checkout.sessions.create({
    line_items: line_items,
    mode: "payment",
    metadata: {
      humblytics_view_id: humblytics_view_id,
    },
  });

  return new Response(JSON.stringify({ sessionId: session.id }), {
    status: 200,
    headers: { "Content-Type": "application/json" },
  });
}

Once connected and metadata is properly passed, Humblytics will automatically attribute revenue to the correct marketing channels. No webhook setup is required.

After receiving a successful payment, you should see revenue data in your dashboard (referrer, country, browser, etc.). If you don't, please contact us at [email protected].

Key Benefits

Benefit
Detail

Automatic attribution

Revenue automatically linked to visitor data

No webhooks needed

Simple metadata-based tracking

Privacy-compliant

Cookie-free tracking, no consent banners

Split test ready

Use revenue as conversion goals in A/B tests

Setting Up Split Tests with Revenue Goals

  1. Create a split test on your main website

  2. Choose Revenue as your goal type

  3. Set your target revenue amount or use "Any Revenue" for all purchases

  4. Launch your test - revenue will be automatically tracked

Troubleshooting

  • No revenue data appearing? Check that your Stripe account is properly connected

  • Missing attribution? Verify the metadata is being passed correctly in your checkout session

  • Need help? Contact [email protected] for assistance

Last updated

Was this helpful?