Skip to content
Every tutorial here is 100% free — and always will be
LSLovableStudent

How do I install Google Tag Manager?

Last checked 31 Aug 2026

Short answer

Ask Lovable to add your GTM container snippet to the site's shared head and body, then manage individual tags (analytics, ads, pixels) from within Tag Manager itself.

Setup steps

  1. Create a container in Google Tag Manager and copy the two snippets it gives you (one for <head>, one right after <body>).
  2. Ask Lovable:

"Add my Google Tag Manager container GTM-XXXXXXX to the site, with the head snippet in the document head and the noscript snippet right after the opening body tag, on every page."

Why GTM instead of individual scripts

If you expect to add or swap tracking tools over time (analytics, ad pixels, conversion tracking), GTM lets you manage them from the Tag Manager interface without asking Lovable to edit code each time. For a single, permanent tracking script, adding it directly (see /questions/how-do-i-connect-google-analytics) is simpler.

Single-page app note

Same caveat as GA4: Lovable apps navigate client-side, so GTM's default "Page View" trigger only fires on the first load. Set up a custom trigger listening for route changes, or ask Lovable to push a dataLayer event on each route change:

"Push an event to the dataLayer named 'route_change' whenever the route changes, so I can use it as a trigger in Tag Manager."

Verifying it works

Use GTM's built-in Preview mode against your published or preview URL — it shows exactly which tags fired and what data layer values they saw.

What usually goes wrong

  • Only adding the head snippet and skipping the body/noscript snippet — fine for most tags, but technically incomplete per Google's instructions.
  • Tags configured in GTM but never published (GTM has its own separate "Publish" step distinct from Lovable's Publish).
  • Duplicate tracking because both a direct GA snippet and a GTM-managed GA tag are live at once — pick one path.
  • Ad blockers and browser tracking protection affecting a portion of visitors regardless of setup.

Sources

Was this answer helpful?

Related questions

Website made, maintained and hosted by PromptSites.com

PromptSites logo