Google Tag Manager revenue tracking: add Virling in minutes
By Devendra Variya, co-founder of Virling. Published 2026-11-21, updated 2026-11-25.
If your site already runs Google Tag Manager, you can add Virling there in a few minutes without touching the site's code. Import the ready-made Virling container, or add one Custom HTML tag that fires on all pages, then publish. The script records the referrer and UTM tags of every visit against a visitor ID. Once you connect your payment provider, each payment is joined to the visit before it, and you see revenue per channel: which search, post, ad or campaign brought paying customers, not only clicks.
Why use Tag Manager for revenue tracking
Marketers and agencies often get access to a client's Tag Manager long before they get access to the site's templates. Adding Virling as a tag means one publish instead of a code change, and it sits next to the other tags you already manage. What Virling adds is the payment side: it ties each sale to the visit that came before it, which is what revenue attribution means. The tag itself is the same small script used on every other setup.
Option 1: import the Virling container
Download integrations/gtm/virling-container.json from the Virling repository. In Tag Manager:
- Open Admin, then Import Container, and choose the file.
- Pick your workspace and choose Merge, so your existing tags stay as they are.
- The import adds a Virling tag that fires on all pages and two constants, Virling server and Virling site. Set Virling server to your Virling address,
https://app.virling.comon the hosted version, and Virling site to your site domain. - Click Submit to publish.
Option 2: add a Custom HTML tag by hand
Add a new tag of type Custom HTML, paste the tag below, set its trigger to All Pages, and publish. The app shows the exact tag for your site:
<script defer src="https://app.virling.com/v.js" data-site="yourdomain.com"></script>
Tag Manager keeps the tag's attributes when it injects it, and the script reads data-site from its own tag, so leave the attributes as they are. Both options are in the framework setup docs, under Google Tag Manager.
Ad blockers and Tag Manager
Ad blockers that block Tag Manager block the Virling script with it, so visits from those browsers are not recorded; ad blockers and missing revenue shows how to size that gap. If that matters for your site, add the tag directly to the page before </head> instead of loading it through Tag Manager. Everything else works the same either way.
Check the first pageview
After publishing, open your site in another tab. The setup screen in the Virling app updates on its own when the first pageview arrives. You can also open the browser's network panel and look for a POST to /api/event that returns 202.
Connect payments to see revenue per channel
Pageviews alone show traffic. To see revenue per channel, add your provider under Payment connections in site settings; Stripe takes a restricted key with Read access. For Stripe, Polar, Dodo Payments and LemonSqueezy checkout links on your pages, the script adds the visitor ID to the link by itself. If your own code creates the checkout on the server, pass the virling_vid cookie as described in the checkout docs and in server-side revenue tracking. Every provider and store Virling connects to is on the integrations page.
Channels come from the referrer and the UTM tags on the landing URL, so tag your campaign links consistently. UTM parameters for revenue tracking covers which tags to use, and the UTM builder makes the links. If you run search ads, see Google Ads revenue per campaign; unpaid search visits need no tags, and organic search revenue shows how to read them.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| No pageview | The container is not published, an ad blocker stopped Tag Manager or the script, or data-site does not match the domain in Virling. The script also sends nothing on localhost, in a browser opted out with #virling-ignore, or with Global Privacy Control on when the tag has data-respect-gpc. | Click Submit, then test the published site in a private window with extensions off. Set data-site, or the Virling site constant, to the domain exactly as you added it, without www. or a path. |
| Double pageviews | The script is loaded twice: in the site's templates and in Tag Manager, through both options above, or by a tag that fires again on a History Change trigger. Each copy sends its own pageview. | Load it once, with one tag on All Pages. Route changes are sent on their own. |
| Consent mode blocks the tag | Virling does not read a consent tool's signals. If the tag's consent settings in Tag Manager require consent, it does not fire for a visitor who has not given it. | To count every visit and set the cookie only after consent, set Visitor cookie to Until consent in site settings, add data-cookieless to the tag, take the consent requirement off it, and call virling("consent") from your consent tool when the visitor accepts. To send nothing before consent, fire the tag from your consent tool's callback. |
| Payments Unattributed | No visitor ID reached checkout, the site is cookieless or the visitor has not accepted under Until consent, the tag was missing or blocked on the visit, or no visit falls inside the lookback window. | Open the payment and look for Visitor under Details. With no ID, pass virling_vid into checkout. With an ID, run the tag on every page where visitors arrive, or choose a longer lookback window. Payments made before the fix usually stay Unattributed. |
The full lists are in the docs: add the script, privacy and consent and Unattributed revenue.
Frequently asked questions
Can I install Virling with Google Tag Manager?
Yes. Import the ready-made container from integrations/gtm/virling-container.json in the Virling repository, or add one Custom HTML tag with the Virling script and an All Pages trigger. Publish the container and the script runs on every page.
What does the Virling GTM container add?
One tag named Virling that fires on all pages, and two constants, Virling server and Virling site. Set them to your Virling address and your site domain, then submit to publish.
Do ad blockers affect Virling in Tag Manager?
Ad blockers that block Tag Manager block the Virling script with it. If that matters to you, add the script tag directly to the page instead of loading it through Tag Manager.
How do I check that the GTM tag works?
Open your published site in another tab. The setup screen in the Virling app updates on its own when the first pageview arrives. You can also watch the browser's network panel for a POST to /api/event that returns 202.
Does the tag alone show revenue per channel?
No. The tag records visits and their sources. Revenue appears once you connect a payment provider in Virling and each payment carries the visitor ID, which the script adds to Stripe, Polar, Dodo Payments and LemonSqueezy checkout links on its own.
Does Virling work with Google Consent Mode?
Virling does not read consent signals, so you choose when it runs. Fire the tag only when the visitor accepts, or set Visitor cookie to Until consent, add data-cookieless to the tag and call virling("consent") when the visitor accepts. The second way counts every visit and sets the cookie only after consent.
Do I need a History Change trigger for a single-page app?
No. The script sends a pageview on its own when the path or the query string changes, so one All Pages trigger is enough. Firing the tag again on a History Change trigger loads a second copy, and each copy sends its own pageviews.
See which channels bring revenue, straight from Tag Manager
Virling is open source under AGPL. Self-host it free, or use the hosted version with a 14-day free trial. It connects to Stripe, Paddle, Shopify, WooCommerce, Polar, LemonSqueezy, Dodo, Creem and RevenueCat.