Tracking and attribution

How a click on a partner's link becomes a customer and a commission. It works like Rewardful or Tolt: MRRocket counts the click, the SDK on your site keeps the referral, and your payment provider tells MRRocket who paid.

Verified against local fakes of Stripe and RevenueCat and in the running app. No real Stripe account or App Store purchase has been attributed yet.

Every partner gets both, in their portal under Link:

  • Tracked link https://<your MRRocket>/r/<code>: counts the click, then sends the visitor to your site (the program's Links go to, default your product's domain) with ?mrr_ref=<code>&mrr_click=<id> added. utm_* parameters are kept, and ?to=/pricing opens another page of your site.
  • Direct link https://your.site/?ref=<code>: goes straight to your site; the SDK reports the click.

Bots are stored apart and never counted, link previews and prefetches are ignored, and the same visitor counts once per partner in 30 minutes. MRRocket stores no IP address, only a salted hash that changes every day. An unknown or paused code still opens your site, without a referral.

On your site: the SDK#

The referral cookie must belong to your domain, not MRRocket's, so the SDK sets it. With <CockpitProvider> in your layout nothing else is needed:

<CockpitProvider consent={consent}>{children}</CockpitProvider>

On page load the SDK reads mrr_ref/mrr_click (or ref), keeps the referral in the mrr_ref cookie and localStorage for the program's Referral kept days (default 60), and sends a click beacon for direct links. Your own events, identify() and signups carry the referral as $referral.

PropDefaultWhat
attribution"consent""consent": stored only while consent="cookies", otherwise kept for the page load. "always": stored whatever the consent. "off": ignored.
referralParam"ref"The parameter of direct links, for example "via".

The referral cookie is a tracking cookie. In the EU and UK it needs the visitor's consent unless your lawyer finds another basis, so keep the default attribution="consent" and switch your banner's "accept" to setConsent("cookies"). Without consent the referral only lasts for the page the visitor landed on.

Stripe#

Pass the referral to Checkout. In a client component:

import { referralForCheckout } from "@mrrocket/sdk/next";
// send referralForCheckout() to your server with the checkout request

On the server, from the cookie:

import { cookies } from "next/headers";
import { readReferralCookie, referralForCheckout } from "@mrrocket/sdk/next/server";
 
const ref = referralForCheckout(readReferralCookie((await cookies()).get("mrr_ref")?.value));
const session = await stripe.checkout.sessions.create({
    mode: "subscription",
    line_items: [{ price, quantity: 1 }],
    ...(ref ?? {}),
    subscription_data: { metadata: ref?.metadata ?? {} },
    success_url, cancel_url,
});

referralForCheckout() returns { client_reference_id: "mrr_ref:<code>:<clickId>", metadata: { mrr_ref, mrr_click } }, or null without a referral. For a Payment Link use referralLink(paymentLinkUrl), which adds client_reference_id=mrr_ref__<code>__<clickId> (Payment Links allow only letters, digits, - and _).

A promotion code that equals the partner's code attributes too, without any code on your side.

In Stripe's webhook endpoint add checkout.session.completed to the 20 events Settings lists. Without it MRRocket finds the Checkout Session through the new subscription instead (the key needs read access to Checkout Sessions).

RevenueCat (apps)#

Two ways, both on the RevenueCat customer:

  • Offer code: give each partner an App Store offer code (or a Google Play promo code) equal to their MRRocket code. RevenueCat sends it as offer_code with the purchase.
  • Attribute: when your app knows the referral (a deep link, or the web SDK's cookie handed over at sign-up), set it before the purchase: Purchases.setAttributes({ "$mrr_ref": code, "$mrr_click": clickId }).

What MRRocket books#

  1. A customer is tied to a partner#

    On the first signal (Checkout, subscription, invoice, purchase), one referral per customer: the first partner wins. A click older than the referral window is ignored. A partner buying through their own link or code is blocked and logged.

  2. Every payment earns#

    By the partner's terms: a share of each payment for the set months (counted from the first paid payment), or a fixed amount for the first sale. Stripe: the amount without tax, before Stripe's fee. RevenueCat: the store's proceeds (without the store's commission and tax). Converted to US dollars. Trials earn nothing until they pay; upgrades and plan switches earn their share of what is paid.

  3. The hold, then the payout#

    A sale line is Pending for the hold days, then Approved into the partner's next payout. Refunds and lost disputes reverse it; after it was paid, a negative line goes into the next payout.

Replayed webhooks and the scheduled catch-up never add a line twice.