Use Google Tag Manager with Analytics
There are two different ways you can include Google Analytics tracking code in your website. The first is the easiest and most straight-forward. Google Analytics gives you a block of code to insert into the heading of your website. If you include it in your theme or template, it will be included on every page and work great.
The Cons
The drawback to doing it this way is that it becomes difficult to manage or adjust. Big deal, right? Once you set your Analytics code in place how often does it really change? Well, in a situation like the one we’re in right now (Switch to Google Analytics GA4 before July 2023), it can be a little difficult. Especially if you wan to run multiple instances of analytics simultaneously.
The Solution
The solution is to instead use Google Tag Manager. Instead of injecting the analytics code directly into your website, you insert a container. That container can then have multiple tags included from a third party interface. That allows you to have multiple tags. Google Analytics UA and GA4 instances are just the beginning of the tags you can include in your Tag Manager container. Additional tags could be everything from a Facebook verification code to a timer tracking how often paid search visitors spend more than 5 minutes on your landing page. The possibilities are truly endless!
The next time you need to change or set up Analytics, take a minute to learn what Google Tag Manager can do for you.