Andrew Maidah

Boost Your Google Lightspeed Scores with One Change

One simple trick that Google doesn't want you to know!

[object Object]
by Andrew Maidah
tl;dr don’t load Google Tag Manager for bots

An Innocent Request

We’ve all gotten this message:

Can you install and give us access to Google Tag Manager?

There’s nothing wrong with this request. In fact, it’s the standard way for marketers and analysts to load ad trackers and analytics scripts. Google recommends this approach.

It’s standard. Totally standard.

But it completelys destroys Google’s own performance metrics.

A simple e-commerce website driving paid traffic might have the following being loaded through Google Tag Manager as a baseline:

  • Google Analytics
  • Google Ads
  • Google Conversion Linker
  • Meta Pixel
  • Universal Event Tracker (Microsoft)
  • Pinterest Tag
  • Reddit Pixel
  • Mixpanel Tag
  • LinkedIn Tag
  • Adroll Smart Pixel
  • Custom Script Tags

Often the combined weight of these trackers can be 2x the total size of your actual page! It’s unbelievable and it tanks Lighthouse scores.

First Contentful Paint, Time to Interactive, Total Blocking Time, Bandwidth, Unused JavaScript, and more.

I Get It, Show Me The Fix

Why are we even loading marketing and analytics scripts for bots and scrapers?

Just don’t load Google Tag Manager for bot traffic. Bots don’t need marketing trackers or popups.

If you load in Google Tag Manager manually:

useEffect(() => {
  const isBot = isbot(navigator.userAgent);

  if (isProd && !isBot) {
    loadGoogleTagManager(GTM_ID);
  }
}, [rootData.isProd]);

But the concept can be applied to anything heavy that a bot doesn’t care about:

isBot ? (
  // save bandwidth costs!
  <Layout {...data}>{children}</Layout>
) : (
  <ExpensiveMarketingOrAnalyticsProviders>
    <Layout {...data}>{children}</Layout>
  </ExpensiveMarketingOrAnalyticsProviders>
);

Lighthouse Proof

Let’s use my site as an example. Fairly light site with just Google Analytics and Google Ads loading through Google Tag Manager.

400kb extra weight with a blocking time of ~1s by loading GTM!

20 point boost by not loading GTM for the Lighthouse bot!

This Does Not Change User Experience

But Andrew, the users will still load all these scripts! This just boosts your Google Lighthouse scores without changing anything really.

Yes, this will help you look better if your bonus is tied to your CEO running Lighthouse or WebPageTest but not much changes for real users.

Actual improvements for users with server-side tagging is a separate topic for later.