Skip to main content
More in Learn

How to Reduce the Impact of Third-party Code Google Tag Manager?

Third-party code such as Google Tag Manager (GTM) can sometimes affect website performance, including load times and user experience, due to additional HTTP requests, render-blocking resources, or heavy CPU usage. We talked extensively in our The Cost of 3rd Party Scripts: Understanding and Managing the Impact on Website Performance blog post. Also, be sure to read Performance Tricks and Hacks post as well, where we go behind the scene of the perfect 💯performance score of our website.

Here we wanted to share several strategies you can implement to mitigate impacts your GTM specifically can enforce on website performance. Keeping websites fast when loading Google Tag Manager is another excellent example of learning in public about GTM by looking at what we did.

OK. So, what can you do?

Audit your Tags. Start by conducting an audit of all the tags you have in GTM. Remove any tags that are outdated or no longer needed. This reduces unnecessary third-party code, helping to improve your website's performance.

Prioritize and Defer Tags. Not all tags need to fire immediately when a page loads. If a tag isn't required immediately, use the tag sequencing or trigger conditions options in GTM to delay its firing. This allows crucial website content to load first, improving perceived load times.

Use Async Attributes. Ensure the async attribute is enabled if a tag doesn't modify the DOM (Document Object Model). This attribute allows the browser to continue building the webpage while the script is still loading, which can prevent render blocking.

Limit the Data Layer. The more data you push to the data layer, the more processing power is required to handle it. Limit the data layer to only the most necessary variables and events.

Minimize Custom HTML Tags. Custom HTML tags can add significant bulk to your container. If possible, use GTM's built-in tag templates, as these are generally more optimized.

Use a Content Delivery Network (CDN). CDN can cache your website and serve it from a location closer to your visitors, which can speed up the loading time of third-party scripts.

Monitor Performance. Regularly monitor your website's performance using tools such as Google's Lighthouse or PageSpeed Insights. These can provide insights into how your tags are affecting performance and where improvements can be made.

By efficiently managing your use of Google Tag Manager, you can reduce its impact on your site's performance, ensuring faster load times and a better user experience. Remember, it's crucial to balance your website's performance with the functionality provided by third-party scripts.

Wanna learn more? Check out our frontend performance checklist, a cumulative list of items we at Crystallize found important when creating our website.

People showing thumbs up

Need further assistance?

Ask the Crystallize team or other enthusiasts in our slack community.

Join our slack community