Google Tag Manager Script reducing page performance
Asked Answered
M

2

7

When I place google tag manager script in the head part of my website as strongly recommended by google;

the script basically delays the onload event causing to increase the Time To Interact of the page.

I had a work around for this issue by injecting the script after a time of 3000 ms using setTimeout() function.

This has improved the performance of the website drastically. But this is not recommended by the Google. Since I know there is a problem with the gtm script. Is there a workaround?

Myer answered 9/5, 2019 at 12:29 Comment(0)
I
0

I'm surprised its impacting your site performance that drastically, since it should be async (assuming you used the recommended script tag).

Are you using a datalayer? If not, this should help reduce redundancies and improve performance - you can use custom event triggers that wait for page load to send the layer.

It could also be one or more of your tags causing the delay, you may want to pause individual tags and see if you can find the culprit. Keep in mind that if you are testing in preview mode, page load will be slower.

Intimacy answered 17/6, 2020 at 20:8 Comment(0)
G
-1

I would recommend to use a caching Plugin like WP Rocket, there you can set how to load scripts in order to optimize your pagespeed :)

Gorgias answered 21/3, 2021 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.