Talk to Franz

Article

Load Third Party Dependencies later using Google Tag Manager

Fire third party tags in Google Tag Manager only after the first mouse move, scroll, focus or touch. Users trigger these events, Google and other bots do not.

load 3rd parties delayed

Key takeaways

  • Deploy every third party dependency via Google Tag Manager.
  • One Custom HTML tag fires the event "minimal-user-interaction" once per pageview.
  • Load conversion tags, ad tags and other tags on that event at the earliest.
  • Do not delay Google Analytics, otherwise the bounce rate is falsified.
  • If the browser jitters once the tags load, start deleting tags.

You do everything in the book for a green Page Speed Insights rating. Then Google says: reduce the impact of third party code.

It is not you, it is:

  • Google Tag Manager
  • Facebook Pixel
  • Google Analytics
  • Google Conversion Tracking
  • 10 000 other external scripts, conversion tools and third party crap

Kicking it all out would be best. There usually is a reason to have it, so make it fast.

Step 1: load third party code via Google Tag Manager

Google Tag Manager (GTM) was a really bad tool in its first years. Now it is a powerful one.

Step 2: create a tag called “minimal-user-interaction”

  • Type: Tag → Custom HTML
  • Name: minimal-user-interaction
  • Code: Github-Gist
  • Trigger: All Pages - Page View

The tag fires the event “minimal-user-interaction” once per pageview, as soon as a user:

  • moves their mouse
  • starts to scroll
  • sets focus (i.e. users with screenreaders)
  • touches their mobile screen

Step 3: create a trigger called “minimal-user-interaction”

  • Type: Trigger
  • Name: minimal-user-interaction
  • Event name: minimal-user-interaction
  • Trigger Type: Custom Event
  • Fires on: All Custom Events

Step 4: move existing tags to the new trigger

Change

to

  • Load all conversion tags, ad tags and other tags after “minimal-user-interaction” at the earliest, or even later.
  • The exception is Google Analytics, otherwise the bounce rate will be falsified. Google still complains about Google Analytics, but you pass the Page Speed Insights test.
  • The tag “minimal-user-interaction” keeps “All Pages” as its trigger: it fires the event.

If the browser jitters, start deleting

Browser “jittering” or unusable as soon as the user does something? Evaluate whether you need everything you load.

All articles