Overview
If your site already uses Google Tag Manager (GTM), you can install the Revshare tracking script without editing your site's code. You add the script once as a Custom HTML tag and set it to fire on every page.
The tracking script finds its own tag by its src, so it works correctly even though GTM injects it into the page dynamically. There are no special GTM-only changes to the snippet.
Before You Start
You'll need:
- Access to your Google Tag Manager container (Editor or Publish permissions).
- Your Program ID, found in your Revshare dashboard on the program setup page.
Setup Steps
- Create a new tag — In your GTM workspace, go to Tags → New, then click Tag Configuration and choose Custom HTML.
- Paste the snippet — Add the script below into the HTML field, replacing
YOUR_PROGRAM_IDwith your Program ID. - Set the trigger — Under Triggering, select All Pages (the built-in “All Pages” page view trigger). The tag must fire on every page so clicks and conversions are attributed correctly.
- Keep firing options as “Once per page” — This is the default and is what you want. You do not need to enable “Support document.write.”
- Submit and publish — Click Save, then Submit and Publish to push the container live.
Standard snippet — for most websites:
<script
async
src="https://www.revshare.so/tracking.js"
data-program-id="YOUR_PROGRAM_ID"
data-cookie-duration="30"
></script>Tracking across subdomains? If visitors land on one subdomain (e.g. www.example.com) but convert on another (e.g. app.example.com), add the data-domain attribute so the cookie is shared:
<script
async
src="https://www.revshare.so/tracking.js"
data-program-id="YOUR_PROGRAM_ID"
data-domain=".example.com"
data-cookie-duration="30"
></script>See Cross-Domain Tracking for details.
Consent & Cookie Banners
If your GTM setup uses a consent management platform (CMP) or Google Consent Mode, make sure the Revshare tag is allowed to fire under your analytics or marketing consent category. If the tag is blocked until consent is granted, referral cookies won't be set and sales may go unattributed.
Tip: In the Custom HTML tag's Advanced Settings → Consent Settings, review the additional consent required so the tag behaves the way you expect under your CMP.
Verify It Works
- Use GTM Preview mode — Click Preview in GTM, enter your site URL, and confirm the Custom HTML tag shows as Fired on the page.
- Check the console — Open your browser's developer tools. If the Program ID is missing, you'll see a warning:
RevShare: Missing data-program-id attribute on tracking script. - Confirm the metadata object — In the console, type
window.revshare_metadata. When the script is working, it returns an object containing yourprogram_id. - Do a test referral — Visit your site through an affiliate link (e.g.
yoursite.com?ref=test123) and confirm the referral is captured inwindow.revshare_metadata.ref_code.
Shopify Stores
Shopify restricts custom scripts on the checkout, and Shopify uses a dedicated tracking script plus webhook-based conversion tracking. If you're on Shopify, don't install the standard tag through GTM — follow the Shopify Integration Guide and Shopify Tracking Script Setup instead.
