How to set up Google Analytics with Google Tag Manager Server-Side Container?

Google Tag Manager server container has close integration with Universal Analytics. When you set up GTM server tagging, you will see that Universal Analytics Client is created by default. In this article, we will discuss the benefits and possibilities that server-side Google Analytics offers. And also, how to configure Google Analytics in your Google Tag Manager Server account.If you don’t have a GTM server container yet, please follow this instruction on how to launch it on your website. If you are still not sure what GTM server tagging is and how it can benefit your website tracking system, please read this blog post.

What are the benefits of implementing Google Analytics Server-Side tracking?

1. Bypass Ad Blocker and ITPs

There are two ways of implementing Google Analytics within a server-side container: host it on your subdomain or our domain. Hosting on your subdomain gives you the massive benefit of bypassing AdBlocker and Intelligent tracking preventions. A custom subdomain feature is not available in a free plan, so you’ll need to update to one of the paid plans; please check our pricing.

In 2020, roughly 27 percent of internet users are using ad blockers. It means that a bit more than a quarter of paid ads will never reach their audiences. And this number is expected to grow by 2-3% annually. 

Not only ad blockers prevent your tracking from collecting all data about website visitors. Some browsers are now using Intelligent tracking prevention technology, which is designed to stop 3rd party cookies. Firefox launched it in 2019; Safari began using ITP in autumn 2020. Though Chrome still has not announced anything similar to ITP, it started blocking third-party pixels by default in the incognito mode.

Google Analytics with Google Tag Manager Server-Side Container intelligent tracking prevention

Let’s say your website visitor agreed to the cookie policy but he is using an ad-blocking extension. In addition to blocking display ads, it will also block all the requests that are sent to Google Analytics. In this case, GA doesn’t receive any information; you won’t be able to see this user’s data and remarket him when he is browsing other websites.

Google Analytics with Google Tag Manager Server-Side Container collect google analytics domain

With server-side tagging, you could create a tagging URL within a custom subdomain that is located in the same hierarchy as your website domain; for example, gtm.yourdomain.com. In this case, collect requests will be sent not to google-analytics.com, but your gtm.yourdomain.com. This way, you will make GA request the first party, and it would be blocked by ITPs and AdBlockers. 

Google Analytics with Google Tag Manager Server-Side Container collect google analytics domain custom subdomain

2. Increase cookie lifetime. 

Safari and Firefox are limiting the cookie lifetime to 7 days or, in some cases, to 24 hours. It means that unless a user is revisiting your site every day and cookies are continuously updated, it will expire in 1 or 7 days. And Google Analytics will record these visitors as new. There is a website that helps you to track the latest information about browser storage updates.

Currently, the only way to avoid this is to run Google Analytics via Server-Side Google Tag Manager. This feature is enabled by default, but we recommend checking it to be 100% sure that cookie lifetime is set up to a more extended period.

Google Analytics with Google Tag Manager Server-Side Container collect google analytics domain increase cookie lifetime

How to Set Up Google Analytics Inside Google Tag Manager Server-Side Container?

  1. Create Google Tag Manager Server-Side container if you haven’t created one. Please follow these instructions
  2. Add a custom subdomain if you want to bypass adblockers and increase cookie lifetime. Follow these instructions
  3. Make sure you’ve changed the tagging URL inside your Google Analytics variable within Google Tag Manager Web Container. Inside Google Tag Manager Web Container, go to Variables -> Choose your Google Analytics variable -> More Settings -> Advanced Configuration -> Past Transport URL.

Google Analytics with Google Tag Manager Server-Side Container collect google analytics domain change transport URL

4. Set up Universal Analytics Tag inside GTM Server Container. Open the “Tags” section inside Server-Side GTM Container and Click “New.”

Name Your Tag, choose tag type “Universal Analytics.”

Create a trigger. Trigger type “Custom,” choose “Some Events.” Client Name equals Universal Analytics. 

You might not see the Client Name variable in the dropdown. In this case, open the Variables tab, click Configure, and enable all variables.

Click Save.

google analytics request inside gtm server set up server google analytics

google analytics request inside gtm server set up server google analytics trigger

configure GTM Server Variable variable

5. Now let’s open the preview mode of your server Google Tag Manager and make sure that it sends events to Google Analytics. You should see your standard pageview event and custom events that you send via web GTM.

Google Analytics with Google Tag Manager Server-Side Container collect google analytics domain test events

That’s it! Now your Google Analytics runs via server container. Please let us know if you have any questions or need clarifications about implementing server Google Analytics.