Source: https://datafa.st/docs/polar-other-methods
Markdown source: https://datafa.st/docs/polar-other-methods.md
Description: Track Polar payments using customer email for any payment method. Works with custom checkouts, subscriptions, and third-party integrations.

# Attribute revenue with Polar (other methods)

← [Revenue attribution guide](/docs/revenue-attribution-guide)

# Attribute revenue with Polar (other methods)

> If you're using Polar Checkout API, follow [this guide](/docs/polar-checkout-api) instead. If you're using Polar Checkout Links, follow [this guide](/docs/polar-checkout-links) instead. Make sure you've [connected your Polar account](/docs/connect-payment-provider) first.

Use the JavaScript snippet below to track revenue after successful payment by passing the customer's email:

```javascript
// Track revenue after successful payment using email
window.datafast("payment", { email: "customer@example.com" });
```

> Pass the actual email of the customer to the payment event.

## Example implementation

Let's say your customers are redirected to a `/welcome` page after completing a checkout. You want to fire the DataFast payment event on this page. Using React, you can do this like this:

```jsx
"use client"

import { useEffect } from 'react';

export default function Dashboard({ user }) {

  useEffect(() => {
    window.datafast("payment", { email: user.email });
  }, [user]);

  return (
    <div>
      <h1>Welcome to the app!</h1>
    </div>
  );
}
```

### Ensure reliable tracking (recommended)

Add this script to the `<head>` of the page that tracks the payment to guarantee that the payment event is captured even when triggered before the main script loads:

```html
<script id="datafast-queue">
  window.datafast = window.datafast || function() {
    window.datafast.q = window.datafast.q || [];
    window.datafast.q.push(arguments);
  };
</script>
```

## When to use this method

- Third-party payment processors that use Polar
- Mobile app payments

## Important notes

- Duplicate payment events are ignored so you don't need to worry about sending multiple events for the same payment
- Works with any payment flow as long as you have the customer's email

> After receiving a successful payment, you should see revenue data in your dashboard (referrer, country, browser, etc.).
