Skip to main content

Set up Stripe with Tolt

Connect Stripe so Tolt can track the customers and payments your partners refer.

Written by Nick

Connect Stripe so Tolt can track the customers your partners refer and the payments they make. You connect your Stripe account, add Tolt's tracking script to your site, and send each customer's referral ID to Stripe.

This guide covers Stripe Checkout sessions and the Subscriptions API. For Payment Links, Pricing Tables or Buy Buttons, see the guides under Good to know.

Add the integration

  1. Go to Settings › Integrations and click Add integration.

  2. Select Stripe and click Continue with Stripe.

    Add integration dialog with Stripe selected
  3. Open the tab that matches how you take payments: Checkout session or Subscription API.

    Stripe integration page with the Checkout session tab selected
  4. Under Connect your Stripe account, click Install the Tolt app and follow the steps in Stripe.

Add the tracking script

Copy the script from Add the Tolt tracking script to your site and paste it into your website's <head> tag. It already includes your data-tolt ID:

<script async src="https://files.tlt-cdn.com/tlt.js" data-tolt="YOUR-DATA-TOLT-ID"></script>

Add it to every page, including your landing pages and app pages, so no visit through a partner link is missed. The script is about 4 KB. If you use Google Tag Manager, copy the version from the Google Tag Manager tab instead.

Send the referral ID to Stripe

The script stores the visitor's referral ID in window.tolt_referral. Send it from your front end to your server, then add it as tolt_referral in the metadata when you create the checkout session or subscription.

This JavaScript example adds it to a Checkout session:

const session = await stripe.checkout.sessions.create({
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
metadata: {
tolt_referral: req.body.referral,
},
line_items: [
{price: 'price_123', quantity: 1},
],
mode: 'subscription',
});

This JavaScript example adds it to a subscription:

const subscription = await stripe.subscriptions.create({
customer: 'cus_123',
metadata: {
tolt_referral: req.body.referral,
},
items: [
{price: 'price_123'},
],
});

It works the same in any language. If you call the Stripe API from the client side, use window.tolt_referral directly.

Save the integration

  1. Optionally, under Extra, switch on Exclude Stripe tax in the tracking amount to calculate commissions without tax.

  2. Click Save integration.

Tolt now tracks payments, cancellations and downgrades from the customers your partners refer.

Good to know

Did this answer your question?