Revenue attribution

Attribute Polar checkouts created on your server

Read the supr_visitor_id cookie when your server creates a Polar checkout and pass it as metadata, with examples for Node.js, Next.js and Python.

When your server creates the checkout, read the supr_visitor_id cookie from the request and pass it as metadata:

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({ accessToken: process.env.POLAR_ACCESS_TOKEN });

app.post("/checkout", async (req, res) => {
  const checkout = await polar.checkouts.create({
    products: ["<product id>"],
    successUrl: "https://yourdomain.com/thanks",
    metadata: {
      supr_visitor_id: req.cookies.supr_visitor_id,
      supr_session_id: req.cookies.supr_session_id,
    },
  });
  res.redirect(303, checkout.url);
});

supr_session_id is optional: it credits the payment to that exact visit. SuprAnalytics also reads visitor_id from metadata, and the metadata of the customer and the subscription, so renewals keep their attribution.

AI agent or LLM? Read this page as Markdown