Google Tag Manager and page load performance: does it reduces performance in PageSpeed Insights?
Asked Answered
N

3

5

I know this may seem a bit vague, but I'm about to give more context: in the company I work for we use (my personal thought is we're misusing) Google Tag Manager (GTM) to inject some third party scripts inside GTM tags. Mostly we use it to manipulate the DOM in certain page templates (like, for instance, product pages) and inject third party scripts (examples are Zopim chat, Facebook pixel, etc…).

Things we tipically do are: manipulating the DOM when DOMContentLoaded and/or load events happen on page load, so It seems obvious to me that without these GTM tags our site will get a better score in PageSpeed Insights and in Chrome DevTools' Lighthouse. I can't test the website without GTM tags activated since it's already everywhere in the site.

How much is this kind of use of GTM harming our site speed?

Nectar answered 15/1, 2019 at 11:8 Comment(0)
R
7

There are a few different ways in which you can find out the performance impact of GTM and the third party tags.

Via the Developer tools
You can block gtm.js in your browser developer tools. This will prevent loading of Google tag manager and the associated tags. You can find out more about that feature here. Once you have done this, you can run Google Lighthouse from your browser, to see how your scores improve.

Via Webpagetest
You can also use Webpagetest to find out the performance without third party tags. Webpagetest has a request blocking feature or you can use the following Webpagetest script to test out the performance with only your first party domains.

blockDomainsExcept   yourwebsite.com
navigate  https://yourwebsite.com

This is to measure the performance impact of your third party scripts. You probably will get similar results if you include the third party scripts directly into your website without using GTM. That being said, there are ways to optimise your GTM setup for performance and to fully leverage the features of a tag manager to improve the performance of your website. You can check out this article if you are interested in optimizing your GTM setup.

Runlet answered 8/5, 2020 at 5:4 Comment(1)
good point regarding the resource blocker inside the DevTools, very useful! :) I'm reading the article you linked and I'm curious regarding browser compatibility of solutions like using <img /> tag inside a <noscript>…</noscript> block, did you test it directly? Thanks for your effort in explaining all this!Nectar
M
4

Injecting tags is what GTM is for, so this does not constitute abuse.

GTM itself is just a delivery mechanism; it's one JS file (I think an empty container is some 100KB unzipped, and 30KB to download if your browser supports compression) with a mechanism for asynchronous loading of tags. By itself it will contribute very little to the page load time.

Of course the stuff you deploy via GTM might slow down your site a lot - partly because it will download external libraries, and partly because DOM manipulations might force reflows/repaints in the browser. However this is not due to GTM, this is due to the tags you use, and would happen exactly the same if you integrated Zopim etc. via some other means.

So, will using a lot of (potentially bad [1]) JavaScript make your site slow? In all likelihood, yes. It this the fault of GTM? It is not, other than in the sense that GTM makes integrating the nasty stuff a little easier.

[1] Not a dig against you, it's just that marketing tags are quite often written in appallingly outdated JavaScript.

Mittel answered 15/1, 2019 at 11:31 Comment(2)
@eikepierstoff One of my main concerns is related to this question: is Lighthouse/PageSpeed Insights ignoring or not gtm.js? I remember times when the Google PageSpeed was throwing performance issues related to their own Analytics JavaScript file, so I'm thinking they're not ignoring their own js files, but onestly… who knows! :D Thanks for your answer!Nectar
@Nectar - Agree 100%. Still Google is not ignoring GTM files. Removing GTM improves my PSI (Pagespeed Insights) scores by 5 points.Swain
S
2

Yes, it reduces the Lighthouse performance scores, especially the mobile ones. We have to be very careful adding GTM to our website, especially for the homepage. For my website, GTM was injecting another 5 JS files from different domains. This adds more Round-trip time (RTT)to our application and in-turn add more load to browser.

When I removed GTM from my homepage, it improved Lighthouse performance scores by 5 points. So there should be some kind of suggestions/insights provided by GTM itself whether it is going to impact our website or not.

Swain answered 4/7, 2021 at 4:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.