Auth0 affiliate tracking with Refficks
New accounts in your app's Auth0 sign-up, tied to the partner whose link brought them, so their later payment is credited to that partner.
What it gives you
- Somebody who arrives through a partner's link and then creates an account in your app is tied to that partner. When they later pay, through any payment connection Refficks receives, the sale is credited to the partner who sent them.
- A referral programme that rewards "they create an account" counts it.
What it does not
- The person is named at their first sign-in to your app, which for an account made by email invitation may be days after it was made.
- Only new accounts are named, never every sign-in: somebody who signed up before following a partner's link would otherwise read as an account that partner brought.
- A partner is paid when that person pays, and the payment has to reach Refficks from a connection that names the same email.
- A visitor who has not accepted cookies, or whose browser sends Global Privacy Control, is not named.
Steps
1. Put the Refficks script on every page
Paste the snippet into the head of every page of your app, in its main layout. It records the partner's click when somebody arrives.
2. Mark a first sign-in in Auth0
In Auth0, open Actions → Library → Create Action, choose the Login / Post Login trigger, paste the code below, and Deploy. Then add it to the Login flow under Actions → Triggers → post-login. It marks a person's first sign-in on their ID token, and changes nothing else.
exports.onExecutePostLogin = async (event, api) => { // Says on the ID token whether this is the person's first sign-in. if (event.stats.logins_count === 1) { api.idToken.setCustomClaim("https://refficks.com/first_login", true); } };3. Name them in your app
Add this component to your app and render it once inside <Auth0Provider>. It names the person only on their first sign-in.
import { useEffect } from "react"; import { useAuth0 } from "@auth0/auth0-react"; export function NameNewAccounts() { const { isAuthenticated, user } = useAuth0(); useEffect(() => { if (!isAuthenticated || !user || !user["https://refficks.com/first_login"]) return; (function say(tries) { if (!window.refficks) return tries < 40 && setTimeout(() => say(tries + 1), 250); window.refficks.identify({ email: user.email, external_id: user.sub }); })(0); }, [isAuthenticated, user]); return null; }4. Try it
Open your app through any partner's link, copied from their page under Partners, and create an account. The checks on this guide in Refficks say when the new account was named, and when a sale is credited once that person pays.
Sources
Have an account? Open this guide in Refficks for your own script and the checks that show when it is working. New to Refficks? Create an account.