Stripe (Other Methods)

If you're using Stripe API, follow this guide instead. If you're using Stripe Payment Links, follow this guide instead. Make sure you've connected your Stripe account to Humblytics first.

Use the JavaScript snippet below to attribute the payment to the correct customer journey:

// Attribute the purchase to the logged-in customer
window.Humblytics.trackCustomer(customerEmail);

Replace customerEmail with the email address associated with the successful payment.

Example Implementation

The safest place to call trackCustomer is directly before or after you capture the payment. In a Stripe Elements checkout flow that might look like this:

"use client";

import { useState } from "react";
import {
  useStripe,
  useElements,
  PaymentElement,
} from "@stripe/react-stripe-js";

export default function CheckoutForm({ customerEmail, clientSecret }) {
  const stripe = useStripe();
  const elements = useElements();
  const [isSubmitting, setIsSubmitting] = useState(false);

  const handleSubmit = async (event) => {
    event.preventDefault();
    if (!stripe || !elements) return;

    setIsSubmitting(true);

    // Attribute the revenue right before confirming the payment
    window.Humblytics.trackCustomer(customerEmail);

    const { error } = await stripe.confirmPayment({
      elements,
      clientSecret,
      confirmParams: {
        return_url: `${window.location.origin}/welcome`,
      },
    });

    setIsSubmitting(false);

    if (error) {
      // handle error state
    } else {
      // Optionally confirm again after capture if you redirect instead of using return_url
      // window.Humblytics.trackCustomer(customerEmail);
    }
  };

  return (
    <form onSubmit={handleSubmit}>
      <PaymentElement />
      <button type="submit" disabled={!stripe || isSubmitting}>
        Pay
      </button>
    </form>
  );
}

When to Use This Method

  • Third-party payment processors that use Stripe

  • Stripe Elements implementations

  • Mobile app payments

  • Custom checkout flows not covered by other methods

Important Notes

  • Works with any payment flow as long as you have access to the customer's email

  • Privacy-compliant - cookie-free tracking, no consent banners required

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

Key Benefits

Benefit
Detail

Flexible implementation

Works with any payment flow

Manual control

Track payments exactly when you want

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 that you're passing the correct customer email to trackCustomer

  • Need help? Contact [email protected] for assistance

Last updated

Was this helpful?