Attribute revenue with Polar (other methods)

If you are using the Polar Checkout API, follow this guide instead. If you are using Polar Checkout Links, follow this guide instead. Before proceeding, confirm that you have linked your Polar account.

Use the following JavaScript snippet to record revenue after a successful payment by providing the customer's email:

// Record revenue following a successful payment using email
window.flowsery("payment", { email: "customer@example.com" });

Supply the actual customer email to the payment event.

Example implementation

Suppose your customers land on a /welcome page after completing checkout. You want to trigger the Flowsery Analytics payment event on that page. In React, here is how to do it:

"use client"

import { useEffect } from 'react';

export default function Dashboard({ user }) {

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

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

Insert this script in the <head> of the page that records the payment. It ensures the payment event is captured even if it fires before the main script has loaded:

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

When to use this method

  • Third-party payment processors built on Polar
  • Mobile app payments

Important notes

  • Duplicate payment events are automatically ignored, so sending multiple events for the same transaction is harmless
  • Compatible with any payment flow as long as you have the customer's email

Following a successful payment, revenue data should appear in your dashboard (referrer, country, browser, etc.).