Stape

How to set up Google Tag Manager Server Container

Author
Stape
Published
October 04, 2020
Also available in

Collecting data about your website visitors is critical for analyzing and improving the online business presence, reaching users, and converting them into customers. 

However, collecting data is becoming more problematic because of Intelligent Tracking Prevention, AdBlockers, and a decrease in cookie lifetime. Google Analytics and other similar tools will start seeing fewer data about your website visitors and giving you less information to analyze. On the other side, tracking policies and rules make website owners strictly control what data about website visitors they share with 3rd party tools.

To help address these challenges, Google introduces a new feature – Server-Side Tagging to Google Tag Manager. 

What is Google Tag Manager Server-Side Tagging and Why Does it Matter?Copy link to this section

Google Tag Manager (GTM) Server-Side tagging allows website owners to move third-party tracking pixels from their website and start tracking website visitors from the server. It means that the client browser will no longer process tracking pixels. It will be loaded directly from the server.

This approach provides the following benefits:

  • More accurate data;
  • Faster website load time;
  • Extra control over privacy.

Your digital marketing analytic tools (like Google Analytics) can run without executing 3rd party cookies on the client-side. With appropriate server containers set up, you will forget about heavy javascript, blocked 3rd party cookies, and incomplete data in analytics tools. 

If server-side tracking is hosted in your website’s subdomain, all requests will be considered first-party. Google has a detailed description of what is GTM server tracking and how it can benefit your website. 

How to set up Google Tag Manager Server-Side tagging on your website?Copy link to this section

There are many common elements between web and server containers, like tags, triggers, variables, preview mode, etc. The setup of the GTM server-side container is more complex than the standard web container. You will need knowledge of web GTM, Google Analytics, Google Cloud, and web programming in general. I suggest reading this blog post if you wish to set up a GTM server container via a native Google environment. 

We created a service that simplifies GTM server container configuration by removing the part of Google Cloud servers set up, streamlining domain creation, giving you the ability to download Google Analytics from your domain, and making 3rd party cookies 1st party.

👇 This video shows how to set up server Google Tag Manager container

Let's start setting up server Google Tag Manager:Copy link to this section

1. First of all, you need to create a Google Tag Manager Server container. To do that, go to https://tagmanager.google.com/ and choose the account where you want to make a container. Click Admin.

set up google tag manager server container 

2. Under the container column, click +.

create google tag manager server container 

3. Type container name, choose Server, and click create. 

select server in Google Tag Manager 

4. Choose “Manually provision tagging server”, copy your container config and paste it in any text editor. We will need it for the next steps.

server google tag manager manually provision tagging server 

5. Create or login to your account in our service.

6. Once you received the email with the link and set your password, you need to create a container. Enter your container name and paste the container config that you copied from your Google Tag Manager Server Container. Click Create Container.

set up Stape account

7. Once you click create, you will see the status of your container,  container config, and plan name. It takes around 5 minutes to deploy a server container. Please reload the page to update the status. If the setup was done correctly,  you should see the status “Running”. 

If you see “Error” please check that you’ve copied and pasted the correct container configuration. 

If the error repeats contact the support.

8. In this step, you need to set up a tagging URL.

You have two options:

  • use tagging URL that was created for you and is hosted on our domain (stape.io)
  • use a custom subdomain. I highly recommend using this option because it will help to prevent tracking pixels from being blocked and increase cookie lifetime.
set up custom subdomain Stape.io 

If you choose to go with the first option, move to step 9.

If you want to configure a custom tagging URL, click Add custom domain -> log in to your domain name service and create a new DNS record for the subdomain you want to use. You can use any subdomain name you want. (if you are using Cloudflare, select domain -> click DNS -> Add record).

Add these settings:

    Type: A

    Name: ss (or any other subdomain name you want)

    IPv4 address: IP address depends on the location of the servers. You can find the custom domain IP address in your stape.io account.

We have these servers locations:

  • US Center (lowa) => 35.193.123.107
  • US East (South Carolina) => 34.139.101.37
  • US West (Oregon) => 104.198.8.50
  • EU West (Belgium) => 35.195.159.201
  • AP East (Singapore) => 34.126.138.154
  • SA East (São Paulo) => 35.198.36.195

    TTL: Auto

    Proxy status: disable

Your settings should look like this:

set up custom subdomain stape

Once you’ve done add subdomain inside gtm server account. 

add subdomain server GTM

9. The next step depends on the tagging server URL you are using.

You have to options here:

  • If tagging server URL located on our domain, you don’t need to change anything.
  • If you use a custom subdomain, you need to modify the Google Tag Manager code added to your site. Copy the tagging URL and past it instead of www.googletagmanager.com. Make sure you didn’t delete /gtm.js.
update google tag manager domain

10. Add tagging server URL to the Google Tag Manager Server container. Admin -> settings -> container settings. 

set up server google tag manager

11. Update Universal Analytics tagging URL inside WEB GTM container (if you are using GA4 go to the next step). Edit Universal Analytics Base or Universal Analytics Variable inside WEB container -> Click More Settings -> Advanced configuration -> past tagging URL inside the field “transport URL”.  Once done click save and publish web container.   

set up transport URL google analytics 

12. If you are using GA4 follow these steps: Inside the WEB container click edit or create GA4 tag -> enable Send to server container -> add Server Container URL  

Save the tag (this tag should trigger on all pages) and publish container. 

set up google analytics 4 server side 

13. Create Universal Analytics or Google Analytics 4 client inside the Google Tag Manager Server container. Click Clients -> New -> Choose Client type -> Add client name -> Click save.

set up google analytics 4 client

14. Set up Universal Analytics or GA4 tag inside the Server Container. Go to “Tags” section inside Server Container and Click “New.”

Name Your Tag, choose tag type “Universal Analytics” or “GA4”. In case you don’t see these tags go to Clients tab and check that UA and GA4 clients were added, if not add these clients.  

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

Click Save.

set up server side universal analytics tag
set up trigger for server-side universal analytics 

15. Open the debug mode inside your Server Container. Open your website and click on several pages. Go back to the debug tab, you should see Universal Analytics and GA4 requests.

test server side google analytics 

16. Another way to test Universal Analytics and GA4 requests are working via server is to use developers tool. Open your site -> Click alt+command+i (on Mac) or right mouse click and inspect -> go to network tab -> reload the page -> type collect -> click on the request and check that request URL matches your tagging URL. You can do it for both UA and GA4. 

test google analytics serve-side requests

That’s it. Now you’ve set up a server container, and Google Analytics runs via your server container. If you want to load GA within your domain and make GA request 1st party follow these steps to use a custom subdomain.

Tagged with:gtm serverhow to

Host your GTM server at Stape

By signing up you agree to Stape’s Terms of Use and Privacy Notice