Skip to main content
This feature is only available on Business plans and above.
Pearset’s best-in-class Stripe integration listens to payment events on Stripe and tracks them as sales on Pearset.
A diagram showing how lead events are tracked in the conversion funnel
Here are the events that Pearset listens to: In this guide, we’ll learn how to install and set up the Pearset Stripe integration for tracking sale conversion events.

Installing the Pearset Stripe integration

1

Find Pearset on the Stripe App Marketplace

Navigate to the Pearset Stripe Integration on the Stripe App Marketplace.
The Pearset integration page on the Stripe App Marketplace
2

Install the Stripe app

On the top right, click on Install app to install the Pearset app on your Stripe account.
The Stripe integration installation flow
Alternatively, you can also install the Stripe app in a Stripe sandbox first to test your end-to-end flow without involving real money.
Once the app is installed, click on Continue to app settings to finish the installation.
Continue to app settings
3

Connect Stripe to your Pearset workspace

In the app settings page, click on Connect workspace to connect your Stripe account with your Pearset workspace.
Connect Stripe to Pearset
This will redirect you to the Pearset OAuth flow, where you can select the Pearset workspace you want to connect to your Stripe account.
Select the Pearset workspace you want to connect to your Stripe account
Once you click on Authorize, you will be redirected back to the Pearset app settings page on Stripe, where you should see that the integration is now installed.
The Stripe integration is now installed
Once the integration is installed, Pearset will automatically listen to the following events on Stripe and track them as sales on Pearset:
  • customer.created: When a new customer is created
  • customer.updated: When a customer is updated
  • checkout.session.completed: When a customer completes a checkout session
  • invoice.paid: When an invoice is paid (for tracking recurring subscriptions)
  • charge.refunded: When a charge is refunded (for voiding partner commissions)

Tracking sales with the Pearset Stripe integration

Depending on your setup, there are a few ways you can track sales with the Pearset Stripe integration.
When using Stripe Payment Links, lead and sale events are tracked but lead webhooks and lead rewards will not be generated. Sale rewards (both recurring and one time rewards) will still be generated as usual.
If you’re using Stripe Payment Links, simply add a ?dub_client_reference_id=1 query parameter to your Stripe Payment Link when shortening it on Pearset. Then, when a user clicks on the shortened link, Pearset will automatically append the unique click ID as the client_reference_id query parameter to the payment link.
Stripe payment link with Pearset click ID
Finally, when the user completes the checkout flow, Pearset will automatically track the sale event and update the customer’s customerExternalId with their Stripe customer ID for future reference. Alternatively, if you have a marketing site that you’re redirecting your users to first, you can do this instead:
  1. Install the Pearset Tracking script, which automatically detects the dub_id in the URL and stores it as a first-party cookie on your site.
  2. Then, retrieve and append the dub_id value as the client_reference_id parameter to the payment links on your pricing page / CTA button (prefixed with dub_id_).
    https://buy.stripe.com/xxxxxx?client_reference_id=dub_id_xxxxxxxxxxxxxx
    
If you’re using Stripe Pricing Tables – you’d want to pass the Pearset click ID as a client-reference-id attribute instead:
<body>
  <h1>We offer plans that help any business!</h1>
  <!-- Paste your embed code script here. -->
  <script async src="https://js.stripe.com/v3/pricing-table.js"></script>
  <stripe-pricing-table
    pricing-table-id="{{PRICING_TABLE_ID}}"
    publishable-key="pk_test_51ODHJvFacAXKeDpJsgWLQJSzBIDtCUFN6MoB4IIXKJDfWdFmiEO4JuvAU1A0Y2Ri4m4q1egIfwYy3s72cUBRCwXC00GQhEZuXa"
    client-reference-id="dub_id_xxxxxxxxxxxxxx"
  >
  </stripe-pricing-table>
</body>
If you’re using Stripe’s Checkout Sessions API for a recurring subscription service, you might want to check out our Stripe Checkout option instead.If your setup doesn’t involve a lead/signup event and goes straight to the Stripe checkout flow (e.g. for one-time purchases), you can simply pass the Pearset click ID (prefixed with dub_id_) as the client_reference_id parameter to enable conversion tracking with Pearset.
const session = await stripe.checkout.sessions.create({
  success_url: "https://example.com/success",
  line_items: [
    {
      price: "price_xxxxxxxxxxxxxxxx",
      quantity: 2,
    },
  ],
  mode: "payment",
  client_reference_id: "dub_id_xxxxxxxxxxxxxx",
});
If you have a custom checkout flow that uses Stripe’s checkout.sessions.create API, you’d want to associate the Stripe customer object with the user’s unique ID in your database (which we tracked in the lead conversion tracking step). This will allow Pearset to automatically listen for purchase events from Stripe and associate them with the original click event (and by extension, the link that the user came from).
Remember in the lead conversion tracking guide, we passed the user’s unique user ID along with the click event ID in the pearset.track.lead call?
Node.js
await pearset.track.lead({
  clickId,
  eventName: "Sign Up",
  customerExternalId: user.id, // the unique user ID of the customer in your database
  customerName: user.name,
  customerEmail: user.email,
  customerAvatar: user.image,
});
Under the hood, Pearset records the user as a customer and associates them with the click event that they came from.Then, when the user makes a purchase, Pearset will automatically associate the checkout session details (invoice amount, currency, etc.) with the customer – and by extension, the original click event.
First, you’ll need to complete the following prerequisites:
  1. Install the Pearset Stripe integration
  2. Install the Pearset Tracking script
  3. Install the Pearset server-side SDK
Then, when you create a checkout session, pass your customer’s unique user ID in your database as the dubCustomerExternalId value in the metadata field.
Node.js
import { stripe } from "@/lib/stripe";

const user = {
  id: "user_123",
  email: "user@example.com",
  teamId: "team_xxxxxxxxx",
};

const priceId = "price_xxxxxxxxx";

const stripeSession = await stripe.checkout.sessions.create({
  customer_email: user.email,
  success_url: "https://app.domain.com/success",
  line_items: [{ price: priceId, quantity: 1 }],
  mode: "subscription",
  client_reference_id: user.teamId,
  metadata: {
    dubCustomerExternalId: user.id, // the unique user ID of the customer in your database
  },
});
This way, when the customer completes their checkout session, Pearset will automatically associate the checkout session details (invoice amount, currency, etc.) with the customer – and by extension, the original click event.
If you’re using guest checkout (e.g. with mode: "payment"), the customer field in the checkout.session.completed webhook event will be null, and sales won’t be tracked on Pearset.To fix this, set customer_creation to always when creating your checkout session:
Node.js
const stripeSession = await stripe.checkout.sessions.create({
  // ... other options
  customer_creation: "always", // ensures a Stripe customer is created
});

Option 3: Using Stripe Customers

Alternatively, if you don’t use Stripe’s checkout session creation flow, you can also pass the user ID and the click event ID (dub_id) in the Stripe customer creation flow. First, you’ll need to complete the following prerequisites:
  1. Install the Pearset Stripe integration
  2. Enable conversion tracking for your links
  3. Install the Pearset Tracking script
Then, when you create a Stripe customer, pass the user’s unique user ID in your database as the dubCustomerExternalId value in the metadata field.
Node.js
import { stripe } from "@/lib/stripe";

const user = {
  id: "user_123",
  email: "user@example.com",
  teamId: "team_xxxxxxxxx",
};

const dub_id = req.headers.get("dub_id");

await stripe.customers.create({
  email: user.email,
  name: user.name,
  metadata: {
    dubCustomerExternalId: user.id,
    dubClickId: dub_id,
  },
});
Alternatively, you can also pass the dubCustomerExternalId and dubClickId values in the metadata field of the Stripe customer update flow:
Node.js
import { stripe } from "@/lib/stripe";

const user = {
  id: "user_123",
  email: "user@example.com",
  teamId: "team_xxxxxxxxx",
};

const dub_id = req.headers.get("dub_id");

await stripe.customers.update(user.id, {
  metadata: {
    dubCustomerExternalId: user.id,
    dubClickId: dub_id,
  },
});
This way, when the customer makes a purchase, Pearset will automatically associate the purchase details (invoice amount, currency, etc.) with the original click event.
When using Stripe Customers, lead and sale events are tracked but lead rewards will not be generated. Sale rewards (both recurring and one-time rewards) will still be generated as usual.

Tracking free trials

Pearset supports tracking subscription free trials as lead events on Pearset. This is useful for products with free trials since you might want to track trial activations as part of your attribution flow. To enable free trial tracking, go to your Stripe integration settings and enable the Track Free Trials option:
The Stripe integration settings page
Optionally, you can also configure the integration to track the provisioned quantity in the subscription as separate lead events. This is useful if you have a lead-based reward for your partner program and want to reward partners for each unit of the subscription that their customers purchase (e.g. $50 per lead/provisioned seat).
To differentiate between manually tracked lead events and free trial lead events for lead reward types, use the Customer Source reward condition to filter for free trial lead events:
The lead reward free trial condition

Tax handling

When tracking sale conversions from Stripe, Pearset automatically excludes taxes from the final sale amount to ensure accurate revenue reporting. For checkout sessions, Pearset calculates the sale amount by subtracting the tax amount from the total:
// Sale amount calculation for checkout sessions
saleAmount = amount_total - total_details.amount_tax;
For invoices, Pearset uses the total_excluding_tax field when available:
// Sale amount calculation for invoices
saleAmount = total_excluding_tax ?? amount_paid;
This ensures that the sale amounts recorded in Pearset reflect the actual revenue before taxes, providing more accurate metrics for:
  • Revenue tracking and reporting
  • Partner commission calculations
  • Analytics and conversion metrics
Tax amounts are automatically excluded from all sale events tracked through the Stripe integration, including one-time purchases, subscriptions, and recurring invoices.

Currency conversion support

If you’re using Stripe’s Adaptive Pricing feature, Pearset will record the sale amount using the currency of your Stripe account:
checkout.session.completed
// Stripe checkout.session.completed event payload
{
  "id": "{{EVENT_ID}}",
  "object": "event",
  "type": "checkout.session.completed",
  "data": {
    "object": {
      "id": "{{SESSION_ID}}",
      "object": "checkout.session",
      "currency": "cad",
      "amount_subtotal": 2055,
      "amount_total": 2055,
      "currency_conversion": {
        "amount_subtotal": 1500,
        "amount_total": 1500, // this is the amount that Pearset will record
        "source_currency": "usd", // the currency of your Stripe account
        "fx_rate": "1.37"
      }
    }
  }
}
If you’re not using Stripe Adaptive Pricing, Pearset will record the sale amount in the default currency of your Pearset workspace. This means that if you pass a different currency, it will be automatically converted to USD for reporting consistency – using the latest foreign exchange rates.
checkout.session.completed
// Stripe checkout.session.completed event payload
{
  "id": "{{EVENT_ID}}",
  "object": "event",
  "type": "checkout.session.completed",
  "data": {
    "object": {
      "id": "{{SESSION_ID}}",
      "object": "checkout.session",
      "currency": "cad",
      "amount_subtotal": 2055,
      "amount_total": 2055 // this will be converted from CAD to USD
    }
  }
}
The default currency for all Pearset workspaces is currently set to USD. We will add the ability to customize that in the future.

Multiple line items per invoice

When a Stripe invoice or checkout session contains multiple line items (e.g. a base subscription plus an add-on, or several products purchased in a single transaction), Pearset processes each line item individually to calculate the correct commission amount. For each line item, Pearset:
  1. Resolves the Stripe product ID for that line item.
  2. Matches it against any product-specific reward modifiers configured for the partner’s group.
  3. Calculates the commission for that line item using the matching reward rate (falling back to the default reward if no modifier matches).
The final commission recorded for the invoice is the sum of the per-line-item commissions.
For example, if a partner has a 40% reward for prod_gold and a 10% reward for everything else, an invoice with $100 of prod_gold and $50 of prod_addon will generate a commission of ($100 × 40%) + ($50 × 10%) = $45.
The total saleAmount recorded on Pearset still reflects the full invoice total (after tax exclusion and currency conversion), so your revenue analytics remain accurate.

View conversion results

And that’s it – you’re all set! You can now sit back, relax, and watch your conversion revenue grow. We provide 3 different views to help you understand your conversions:
Time-series line chart
  • Funnel chart: A funnel chart view visualizing the conversion & dropoff rates across the different steps in the conversion funnel (clicks → leads → sales).
Funnel chart view showing the conversion & dropoff rates from clicks → leads → sales
  • Real-time events stream: A real-time events stream of every single conversion event that occurs across all your links in your workspace.
The Events Stream dashboard on Pearset

Example apps

Pearset + Stripe Demo App

See the full example on GitHub.