Google Tag Manager affiliate tracking with Refficks
The Refficks script from your Tag Manager container, waiting for your visitors' consent: no code on your pages.
What it gives you
- Partner visits and sign-ups are tracked on a site whose code you cannot edit, through the Tag Manager container you already have.
- The script waits for your visitors' consent through Google's Consent Mode, and forgets a visitor who withdraws it.
- Without Stripe, purchases are reported from the GA4 purchase event your site already sends, and partners are paid on the value without tax and shipping, as Google defines it.
- Nothing secret is involved: the template carries only your publishable key.
- A server-side container can report purchases instead, and can sign them with your own key when you attest they come from your backend.
What it does not
- Visitors who decline cookies are not tracked at all, and neither is a browser that sends Global Privacy Control. Refficks cannot see how many declined.
- A visitor who accepts cookies on a later page than the one they arrived on has lost the partner's code, and is credited to nobody.
- While Stripe reports your payments, no order reported from a browser is recorded (from Tag Manager or from your pages), so a sale is never paid for twice. If Stripe takes only some of your payments, report the others from your server.
- A purchase by a visitor who declined cookies is not reported from their browser. Only Stripe or your server can report it.
- A purchase reported from the browser is marked as unverified unless your server signs it, and never approves itself. The same goes for your server container, unless you attest that its purchases come from your backend.
- The template is imported by hand until it is in Tag Manager's Community Template Gallery, so Tag Manager will not offer you updates. This page says when a newer version is out.
- An ad blocker, or a Content-Security-Policy on your site that does not allow this Refficks's address, stops the script; Tag Assistant then shows the Refficks tag as failed.
Steps
1. Download the Refficks template
It is made for this Refficks: it loads the script from here and from nowhere else.
In Tag Manager, open Templates and choose New under Tag Templates. In the template editor's menu (⋮, top right) choose Import, pick the file, and Save.
2. Add the Tracker tag
Tags → New → Tag Configuration → Refficks, with What this tag does left on Tracker.
Paste your publishable key. It starts rk_pub_, and you copied it when you created it under Settings → API keys. Refficks keeps only its first characters, so if you no longer have it, create another.
3. Choose the consent it waits for
Pick the consent type your cookie banner uses for advertising, usually ad_storage. Until a visitor grants it, nothing is loaded, stored or sent.
Choose Nothing only if the tag's Advanced settings → Consent settings already require consent.
4. Fire it on every page
Triggering: Initialization – All Pages.
5. Optional: add the Sign-up tag
Another Refficks tag, with What this tag does set to Sign-up, the same key and consent type, the new customer's email from a variable, and fired on your sign-up event. It ties the sign-up to the partner who brought them.
6. Optional: add the Purchase tag
Another Refficks tag, with What this tag does set to Purchase, the same key and consent type, fired on your purchase event (Triggering: Custom Event, purchase). It reads the order from the GA4 purchase event your site pushes to the data layer; fill in a field only to read it from somewhere else.
Google defines value as the revenue without tax and shipping, and partners are paid on that. If your value is the whole total the customer paid, tick "My value includes tax and shipping".
If Stripe takes these payments, connect Stripe instead: it reports every payment, verified.
7. Optional: report purchases from your server container instead
If you run a server-side Tag Manager container, import this template there, add a Refficks (server) tag with your publishable key, and fire it on the GA4 purchase event. Use it instead of the Purchase tag, not beside it.
Your GA4 tag in the web container has to pass the visitor on: add an event parameter named rk_vid whose value is a 1st-party cookie variable reading the rk_vid cookie.
Its purchases are unverified, like the browser's, because the purchase event a server container receives usually starts in the shopper's browser. If yours come from your own backend instead, tick "These purchase events come from my own server" and give the tag your signing key's id: the secret from Settings → Tracking goes, base64 encoded, into the key file your SGTM_CREDENTIALS variable points to. Refficks then records those orders as signed by your server container, and a plan that approves by itself may approve them. That is your word, and Refficks cannot check it.
8. Preview, then publish
Preview with Tag Assistant, open your site through any partner's link, copied from their page under Partners, and accept cookies, then Submit and publish. The checks below turn green as the script reports.
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.