Install Linqry with Google Tag Manager
To add Linqry through Google Tag Manager, create a **Custom HTML** tag that builds the tracker's `<script>` element with your site ID, fire it on the **All Pages** trigger, and publish the container. If you can edit your site's HTML directly, a direct install is simpler and more reliable.
Updated · 3 min read
Install with a Custom HTML tag
- Copy your site ID
Start a free trial, add your domain and copy the site ID from the Install page.
- Create a Custom HTML tag
In your GTM container, click Tags → New, open Tag Configuration and choose Custom HTML. Paste the code below and replace the two placeholder values. Leave Support document.write off; the tracker doesn't need it.
<script> window.linqry = window.linqry || function () { (window.linqry.q = window.linqry.q || []).push(arguments); }; (function () { var s = document.createElement("script"); s.defer = true; s.src = "https://linqry.com/t.js"; s.setAttribute("data-website-id", "YOUR_SITE_ID"); s.setAttribute("data-domain", "yourdomain.com"); document.head.appendChild(s); })(); </script> - Fire it on All Pages
Under Triggering, choose the built-in All Pages page view trigger. Don't add a History Change trigger as well (see below). Save the tag with a clear name such as "Linqry".
- Submit and publish the container
Changes in GTM aren't live until you publish them. Click Submit, keep Publish and Create Version selected, name the version and click Publish.
- Check Realtime
Open your site in a new tab and visit a couple of pages, then open Realtime in Linqry. Your page views appear in the live event stream within seconds.
Why the tag creates the script element
The tracker reads its configuration from data-website-id and data-domain on its own <script> tag. Some analytics vendors report that GTM drops custom data-* attributes from script tags pasted into a Custom HTML tag, which would leave the tracker without a site ID, so it would stay silent. Creating the element in JavaScript and setting the attributes with setAttribute doesn't depend on how GTM handles pasted markup. The first statement is the same queue stub as in the standard snippet, so window.linqry calls made before the tracker loads are kept.
GTM also minifies Custom HTML code, which can change single quotes to double quotes. The code above already uses double quotes, so nothing changes.
Single-page apps: no History Change trigger
If your site is a single-page app, it might be tempting to fire the tag on GTM's History Change trigger too. Don't. The tag only needs to run once per full page load: the tracker itself wraps history.pushState and replaceState and listens for popstate, so it records every route change as a page view on its own. Firing the tag again on history changes would load a second copy and count pages twice. If your app routes with the URL hash, add s.setAttribute("data-hash-routing", ""); to the tag.
Sending custom events through GTM
You can call window.linqry from another Custom HTML tag fired by a GTM trigger, such as a form submission or a click on a specific button. Make sure the Linqry tag runs first, or rely on the queue stub, which holds early calls until the tracker loads.
<script>
window.linqry && window.linqry("newsletter-signup", { form: "footer" });
</script>Often it's simpler to skip GTM for events and put a data-linqry-event attribute on the element itself. See custom events and the custom event tracking guide.
When to install directly instead
- Blockers that block GTM block every tag inside it, Linqry included. A direct install only depends on linqry.com loading.
- Load order: the tracker can only start once GTM itself has loaded and fired the tag, so very short visits are more likely to be missed.
- One less moving part: a direct install can't be broken by a container change someone else publishes.
GTM makes sense when you can't edit the site's templates but can publish tags, which is common in larger marketing teams. Otherwise follow the plain HTML install or your platform's guide in the integrations list.
Preview mode and your own visits
In GTM's preview mode, Tag Assistant runs in one window and your actual site in another, so test visits made in preview are counted like any other visit to your domain. To keep your own browsing out of the numbers, run this once in the browser console on your site:
localStorage.setItem('linqry_ignore', 'true')Troubleshooting
- Nothing in Realtime? Check that the container version with the Linqry tag is published, and inspect the page's
<head>for at.jsscript carryingdata-website-id. - Page views doubled? Remove any History Change trigger from the tag, and check the snippet isn't also installed directly in the site's HTML.
- Consent settings in your container? The tag follows whatever consent requirements you configure for it in GTM. The tracker sets no cookies and stores nothing in the browser; whether it needs consent on your site is your decision with your advisor. See the privacy model.
Frequently asked questions
Can I paste the normal two-line snippet into a Custom HTML tag?
It may work, but it depends on GTM keeping the data-website-id and data-domain attributes on the script tag. The version on this page sets them in JavaScript, so it works either way.
Is there a Linqry template in the GTM Community Template Gallery?
No. Use the Custom HTML tag on this page.
Does Linqry read GTM's data layer?
No. Linqry doesn't read dataLayer pushes. To send an event, call window.linqry from a tag, or use data-linqry-event attributes on your elements.
Sources
- Tag Manager Help: Custom tags (Custom HTML) (checked Nov 9, 2026)
- Tag Manager Help: Page view triggers (checked Nov 9, 2026)
- Tag Manager Help: Publishing and versions (checked Nov 9, 2026)
- Tag Assistant Help: Preview and debug (checked Nov 9, 2026)
- Umami docs: Google Tag Manager (data attributes on script tags) (checked Nov 9, 2026)
Related
Paste two lines before </head> on any site you can edit. Works with static sites, server-rendered apps and SPAs.
Send events from JavaScript or plain HTML attributes — plus the events Linqry records for you automatically.
Custom event tracking records the actions that matter on your site, like a button click, a signup or a purchase, in addition to page views. In Linqry you send one with a single HTML attribute or one line of JavaScript, and it becomes something you can count, turn into a goal and use as a funnel step.
What Linqry stores, what it never stores, how visitors are counted, and what that means for cookie banners.
Start measuring your Google Tag Manager site
No card required · 30-day trial · No cookies