Tag managers · 3 min setup
How to add VisitTrack with Google Tag Manager
Updated
The loader is the one VisitTrack's install screen generates for GTM — it creates the script element with data-site set explicitly — plus the one-line queue stub, so tags that fire before the script has loaded can still send events. If you can edit your site's HTML, a direct install is slightly more robust — content blockers that block GTM also block everything GTM loads.
Google Tag Manager at a glance
- Tag type
- Custom HTML
- Trigger
- All Pages (Page View) — once per page
- SPA routes
- Tracked by the script; no History Change trigger
- Consent
- Optional
analytics_storagerequirement in standard mode - dataLayer events
- Custom Event trigger →
window.visitrack("name")
How to install VisitTrack on Google Tag Manager
Step 1: Copy your site id
Add your site in VisitTrack; the install step's Google Tag Manager tab shows the loader with your id filled in (the version below adds the queue stub on top). Replace
SITE_IDbelow.Step 2: Create a Custom HTML tag
In your GTM workspace: Tags → New → Tag Configuration → Custom HTML, and paste the loader.
GTM → Custom HTML tag<script> window.visitrack = window.visitrack || function () { (window.visitrack.q = window.visitrack.q || []).push(arguments); }; (function () { var s = document.createElement("script"); s.defer = true; s.src = "https://visitrack.app/tracker.js"; s.setAttribute("data-site", "SITE_ID"); document.head.appendChild(s); })(); </script>Step 3: Fire it on All Pages, once per page
Under Triggering, choose All Pages. In Advanced Settings → Tag firing options, choose Once per page. Name the tag "VisitTrack" and save.
Step 4: Optional: require consent in standard mode
If you run a consent banner with Consent Mode and keep VisitTrack's standard mode (which stores a first-party id), open Advanced Settings → Consent Settings and require
analytics_storage. In cookieless mode nothing is stored on the device, so you may not need a consent requirement — that's your legal call.Step 5: Preview, then submit and publish
Use Preview to confirm the tag fires on the first page, then Submit → Publish. Nothing reaches your live site until the container version is published.
How to check VisitTrack is working on Google Tag Manager
- In GTM Preview, the VisitTrack tag fires once on the first page and not again on client-side route changes.
- Open the live site after publishing; VisitTrack's live view shows you within seconds.
- DevTools → Network:
tracker.jsloads fromvisitrack.app, then aPOSTto/api/collectper page.
Does VisitTrack track Google Tag Manager page navigation?
The tracker patches the History API, so route changes in single-page apps are pageviews automatically. Firing this tag again on a History Change trigger would insert a second copy of the script and double-count — keep it on All Pages, once per page.
On classic multi-page sites, every page load fires All Pages and the tag runs once, as expected.
How to track custom events and goals in Google Tag Manager
To forward a dataLayer event — say your app pushes { event: "sign_up" } — create a trigger of type Custom Event with that event name, and a second Custom HTML tag that calls VisitTrack. Because the loader defines the queue stub, this works even if the event fires before the script has finished loading.
<script>
window.visitrack("signup", { method: "email" });
</script>Event names are the identifier in VisitTrack — pick one (signup) and keep it. An event named signup fills the Signups tab; any event can become a goal in Settings → Goals. Click goals don't need GTM at all: data-vt-goal="name" on the element works once the script is loaded.
Script options you might need on Google Tag Manager
All optional — add them to the same tag. Full reference: script configuration.
| Attribute | What it does |
|---|---|
data-cookieless | Store nothing in the browser; the server derives a daily-rotating id. See cookieless mode. |
data-exclude="/app/*" | Never track these paths (comma-separated, * wildcard). Checked on every navigation. |
data-allow-local | Track on localhost and *.local — for testing an install only. |
data-debug | Log every event the script sends, and why it skipped one, to the console. |
data-auto="false" | Turn off automatic events (downloads, contact clicks, form submits, rage clicks, JS errors, 404s). |
Google Tag Manager troubleshooting
Pageviews doubled on a single-page app
The tag also fires on a History Change trigger, or VisitTrack is installed directly in the HTML as well. Keep one install and one trigger (All Pages).
Nothing arrives after setup
The container wasn't published, or the tag waits on a consent signal that never comes. Check the tag's status in Preview.
Content blockers stop tracking
Blockers that block googletagmanager.com also stop everything GTM loads. Install the tag directly in your HTML for the most complete data.
Tracked from GTM Preview on localhost
It isn't — localhost is ignored. Preview against your deployed site.
CSP blocks the script
Allow both GTM and VisitTrack: add https://visitrack.app to script-src and connect-src next to your GTM entries.
Google Tag Manager analytics FAQ
Can I install VisitTrack with Google Tag Manager?
Yes. Create a Custom HTML tag with the loader above, fire it on All Pages once per page, and publish the container.
Do I need a History Change trigger for single-page apps?
No. The VisitTrack script listens to the History API itself. A History Change trigger would load it a second time and double-count pageviews.
Does VisitTrack work with Google Consent Mode?
Yes. In standard mode you can require analytics_storage consent in the tag's Consent Settings. Cookieless mode stores nothing on the device. General information, not legal advice.
How do I send GTM dataLayer events to VisitTrack?
Use a Custom Event trigger for the dataLayer event and a Custom HTML tag that calls window.visitrack("event_name"). The loader's queue stub buffers calls made before the script loads.
Is it better to install VisitTrack directly or through GTM?
Directly, if you can edit the HTML: it loads earlier and isn't affected by blockers that stop GTM. GTM is the right choice when marketing manages tags and code changes are slow.
Can I run VisitTrack alongside Google Analytics in GTM?
Yes. They're independent tags. Many teams run both while they compare numbers — see VisitTrack vs Google Analytics.
Keep going
- WordPress analyticsAdd VisitTrack to WordPress with a header-code plugin or a wp_head hook — works with block themes, caching plugins and WooCommerce.
- Shopify analyticsAdd VisitTrack to a Shopify store in theme.liquid, track add-to-cart clicks, and send paid orders back as events — with honest notes on checkout limits.
- Webflow analyticsAdd VisitTrack to Webflow in Site settings → Custom code → Head code, then publish — plus custom attributes for goals and Stripe Payment Link revenue.
- React analyticsAdd VisitTrack to a React single-page app (Vite, Create React App) through index.html — React Router navigations are tracked automatically.
- Install the tracking scriptThe reference tag, CSP notes and how to check it's working.
- Custom events and signupsvisitrack(), data-vt-goal, scroll events and server-side signups.
- Use casesHow SaaS teams, indie hackers, stores and agencies use VisitTrack.
- VisitTrack vs Google AnalyticsCookie-free analytics with revenue attribution, compared honestly.
Add VisitTrack to your Google Tag Manager site
Cookie-free analytics with revenue attribution, live visitors, funnels and session replays. One script tag, every feature on every plan. 14 days free, no card required.
Not on Google Tag Manager? See all 29 integration guides.