Everybody knows it. You work hard to make you website fast and faster. Do everything in the book of webperformance-speed to get the green rating in Page Speed Insights and then after you have done everything an more you get hit with this message:
Reduce the impact of third party code? What? Google is telling me, it’s not me, it’s …..
- Google Tag Manager
- Facebook Pixel
- Google Analytics
- Google Conversion Tracking
- 10 000 other external scripts, conversion tools and third party crap we have on our website!
The best solution would be to just kick all this stuff out, but as there are usually „good“ reasons (or at least „a“ reason) to have them, here is a way to make them fast.
1) Load 3rd crap via Google Tag Manager
Google Tag Manager (GTM) was a really bad tool the first few years of its existence. Nowadays its a pretty cool, powerful power tool. Just deploy every 3rd party dependencies via GTM.
2) Create a new TAG called „minimal-user-interaction“
- Typ: Tag → Custom HTML
- Name: minimal-user-interaction
- Code ➡️ Github-Gist
- Trigger: All Pages – Page View
We create a TAG called „minimal-user-interaction“ that is loaded every pageview, the tag fires an EVENT called „minimal user interaction“. The tag is executed once as soon as a User:
- moves their mouse – or –
- starts to scroll – or –
- sets focus (i.e.: users with screenreaders)
- touches their mobile screens.
These are all events that users trigger, but not Google or other bots.
3) Create a new TRIGGER called „minimal-user-interaction“
- Typ: Trigger
- Name: minimal-user-interaction
- Event name: minimal-user-interaction
- Trigger Type: Custom Event
- Fires on: All Custom Events
We create a TRIGGER called „minimal-user-interaction“, that gets triggered when the EVENT called „minimal-user-interaction“ gets fired.
4) Existing TAGs load based on the „minimal-user-interaction“ TRIGGERS.
i.e.: change
to
I recommend loading all conversion-tags, ad-tags and other tags at the earliest after „minimal-user-interaction“ or even later. All except Google Analytics, otherwise the bounce rate will be falsified. Google then still complains about Google Analytics, but you still pass the Page Speed Insights test.
Note: the tag „minimal-user-interaction“ still has „All Pages“ as a trigger, as this tag is the one that fires the „minimal-user-interaction“ event.
5) That’t it.
Thats it‘.
Note: if you load that much 3rd party crap that the browser starts „jittering“ or becomes otherwise unusable as soon as the users does something, then really evaluate if you need all the stuff that you load. And then start deleting.
Creative way to solve this issue. Thank you!
thx
Hey Franz, das ist eine großartige Lösung!
Aber welche Erfahrungen hast du mit Google Analytics gemacht, dass die Bounce Rate beeinträchtigt wird? Hattest du da zusätzliche Google Analytics Ereignisse auch ausgelöst?
liebe Grüße,
Florian
szenario: user geht auf google und oeffnet pages in neuen tab, besucht aber die seiten nicht.
standard GA implementierung: visit counted as bounce
GA loaded after minimal user interaction: visit not counted at all
thats the reason why i do not recommend to mess with GA. GA is good as its comparable to other projects and website which also have GA installed. If you change how it is installed, the numbers loose their compare-ability.
Hallo Franz,
wir haben deinen Code der die minimal User Interactions erkennt bei unserer Webseite eingebaut, und sind auf zwei Fehler gestoßen:
1. Ein „scrollstart“ Event gibt es nur in jQuery, das entsprechende Vanilla JS Event heißt „scroll“.
2. Ein Event Namens „touchdown“ gibt es nicht, das sollte „touchstart“ heißen.
Wäre cool wenn du den Code anpassen könntest. 😉
LG Stefan
super danke, gefixed. und thx 100 times und more