
By Ben Lipkin on in Analytics
Don’t let your GTM setup get out of control
We love GTM—and the Google Marketing Platform. It lets you quickly build and manage your site’s functionality without hassling your dev team, and that’s a big win. But that convenience can also make it easy to go overboard. Before your site turns into a junk drawer of tracking pixels and marketing integrations, think about what you actually need and check out these quick tips to keep the marketing train rolling without slowing down your site.
Sure, loading GTM code first might give you a better chance of tracking users who leave a page before it finishes loading, but I would argue that your goal should be to make sure your page finishes loading in the first place, so users stay.
Tweaking your triggers
The goal is to implement tags only when and where needed by being more selective with triggers. This may seem like a no-brainer, but when using a default “all pages” trigger is so much simpler, this can be easily brushed off or overlooked.
If you’re not familiar, a trigger is a required component of each tag that specifies when it should be used. For example, you probably don’t need special scripts such as video analytics or chat services on every page of your site. You can prevent unnecessary scripts from slowing pages down by setting up triggers to load them only on the pages where they are needed. Triggers for specific pages are easy to set up and can be re-used throughout your tags, so it’s well worth doing.
Delaying tags or defining custom conditions for when they load is worth considering, too. Think about that chat example or a popup survey—these aren’t needed right away. So if you delay the loading of those scripts by five seconds, or wait until a user has scrolled further down the page, you can allow meaningful page content to load and render first. This is a big win for overall site performance.
There are lots of default triggers to choose from, and timers and other triggers can easily be re-used or combined with other conditions to save time when configuring specific pages.
Avoid changing or inserting content via GTM
There are many ways content can be added to your site via GTM, including adding a simple HTML tag. However, when GTM is used to add or modify your content, it forces the browser to do a reflow–it has to redraw all the page content you see. This process blocks users from interacting and lowers your page-speed scores.
So, while it may be tempting to add or manipulate content this way, without the assistance of a developer, it might not be the best solution over the long term.
Prioritize content and interactivity
You may also want to consider giving your site content and user-facing code priority by loading GTM scripts last. Even though it’s often recommended that GTM code be added at the top of the page so it can start tracking immediately, even if the page hasn’t finished rendering, there’s little reason to do so. Sure, loading GTM code first might give you a better chance of tracking users who leave a page before it finishes loading, but I would argue that your goal should be to make sure your page finishes loading in the first place, so users stay. Then you can measure more meaningful interactions with content. When GTM loads first, you run the risk of slowing the site down and having people leave because scripts have been given priority over the user experience.
That said, it is worth noting that GTM scripts are loaded asynchronously, which means that while they download, the site can continue processing content in the background. This is great, but not ideal. Once the GTM scripts finish downloading, the process is interrupted to execute them. So you might have GTM scripts running before your content and application code (the stuff responsible for design or user interaction) has a chance to run.
In short, you can still delay or even compromise the delivery of meaningful, interactive content by letting your site run GTM scripts first.
Placing the GTM code as close to the bottom of the body as possible—after your application scripts—is the best way to ensure your actual site is given priority. Just change where the GTM snippet is used by moving it to the bottom of the footer.
Every site is different, so check with your engineers on how best to get this done and whether it’s a good fit.
There’s an art to getting all of the information you need and taking advantage of everything new tech has to offer without getting in your audiences’ way. Reach out to FATFREE any time for help finding that balance.