I’m having trouble implementing Google Tag Manager on my HubSpot website. I followed the official HubSpot documentation to add the GTM code through individual page settings, but I’m running into issues with proper placement.
Google Tag Manager requires the code to be positioned immediately after the opening <body> tag for optimal tracking performance. When I tried using HubSpot’s custom module feature to insert the GTM snippet, it automatically wraps my code inside <span> elements, which interferes with GTM’s functionality.
Has anyone found a reliable method to properly integrate Google Tag Manager with HubSpot without these wrapper elements? I need the code to be placed correctly for accurate analytics tracking across all my site pages.
Yeah, this wrapper element thing happens all the time with HubSpot’s content modules. I fixed it by going straight into the template files through Design Manager instead of messing with page-level settings. Go to Design Manager, find your template, and drop the GTM container code right after the opening body tag in the HTML. This skips HubSpot’s automatic wrapping completely. You’ll need template editing permissions, but once it’s in there, your tracking code will work perfectly on every page using that template - no more span element headaches.
try using the tracking code manager in HubSpot. just go to Reports & Data > Tracking Code and drop ur GTM there. it totally avoids those annoying module wraps and is way easier than fiddling with template stuff.
Had this same issue for months until I figured out the Settings route beats messing with templates. Go to Settings > Website > Pages and find the site header HTML section. Drop your GTM container code there instead of fighting with individual page settings or custom modules. This actually puts the code in the document head where HubSpot won’t filter it out. My tags fire way more consistently now compared to template insertion, especially with dynamic content and A/B tests. Just make sure you test everything in GTM’s preview mode to confirm all your tags work across different page types.
To address the GTM integration issue in HubSpot, consider using the footer HTML section instead of the header. While it may seem counterintuitive, the footer HTML actually renders immediately after the body tag opens, avoiding the typical span wrapping problems. Navigate to Settings > Website > Pages, and locate the site footer HTML field to place your GTM code there. This method bypasses HubSpot’s content filters, improving your tracking setup significantly. I’ve found this approach effective when resolving similar tracking issues.