# Stripe (Other Methods)

If you're using Stripe API, follow [this guide](/how-to-track-purchase-events/stripe/stripe-api.md) instead. If you're using Stripe Payment Links, follow [this guide](/how-to-track-purchase-events/stripe/stripe-payment-links.md) 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:

```javascript
// 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:

```jsx
"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 <support@humblytics.com>.

<figure><img src="/files/LMg5TVRvTnqaABjajcln" alt=""><figcaption></figcaption></figure>

## 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

<figure><img src="/files/QtSszJYYXHQwYi1d0rYc" alt=""><figcaption></figcaption></figure>

## 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 <support@humblytics.com> for assistance


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.humblytics.com/how-to-track-purchase-events/stripe/stripe-other-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
