I’m having trouble properly adding Google Tag Manager (GTM) to my Hubspot site. I followed Hubspot’s guide to add GTM through individual page settings, but Google requires the code to be placed immediately after the tag.
I attempted to use a custom module, but it ended up wrapping the code in tags, which isn’t acceptable for Google.
<!-- Example of what I want to avoid -->
<span>
<!-- Google Tag Manager code here -->
</span>
Does anyone have a suggestion for another method to integrate GTM correctly without extra HTML tags? Any advice would be appreciated. Thanks!
hey there! i actually ran into this same issue. wat worked for me was using HubSpot’s ‘Site Header HTML’ option. Go to Settings > Website > Pages > Site Header HTML and paste ur GTM code there. it’ll insert it right after the tag on every page. no extra tags, no fuss. hope this helps!
I’ve dealt with this GTM integration challenge in HubSpot before, and I found a solution that worked well for me. Instead of using individual page settings or custom modules, I leveraged HubSpot’s global content settings.
Navigate to Settings > Website > Global Content. You’ll find a field called ‘Site Footer HTML’. Despite its name, you can actually use this to insert code right after the opening tag. Paste your GTM code here, and HubSpot will automatically insert it in the correct position on every page of your site.
This method ensures the GTM code is placed exactly where Google requires it, without any extra HTML tags. It’s also a centralized approach, so you don’t have to worry about implementing it on individual pages or themes. Just remember to clear your cache and test thoroughly after implementation to ensure everything’s working as expected.
I’ve grappled with this issue before, and I found a workaround that might help. Instead of using individual page settings or custom modules, try editing your theme’s header.html file directly. In the Design Manager, locate your theme’s header.html and insert the GTM code immediately after the tag. This method ensures the code is placed exactly where Google requires it, without any unwanted wrappers.
Remember to test thoroughly after implementation. Also, if you’re using multiple themes, you’ll need to repeat this process for each one. It’s a bit more manual, but it gives you precise control over the code placement and meets Google’s requirements.