The new Google Tag Manager Web Container client for server-side tagging – News Couple
ANALYTICS

The new Google Tag Manager Web Container client for server-side tagging


By introducing server-side tagging in Google Tag Manager, you can do a variety of things from your server side agent Mind boggling:

  • scale down Client side bloat By integrating and distributing data flows to server-side vendor endpoints.
  • to improve data security By adding safeguards and validations to prevent malicious data from being sent to vendor endpoints.
  • Enrich On the data server side, by combining incoming data streams with data from APIs and data stores that you own and control.
  • Remove 3rd party Downloads from the browser by creating proxies for it via a server side container.

This last point is what this article expands on. If you take a look at this video (it goes straight to the relevant part) you can see how common libraries like analytics.js And gtag.js.

Basically, the container on the server downloads the library from Google and then serves it to the browser. This way the library download happens in a first-party context (assuming you’ve configured the endpoint to run on your own domain namespace), and you can freely modify things like cache headers.

With the latest update, the Google Tag Manager server container now allows you to proxy a file Google Tag Manager Web Container Moreover.


X


Simmer . Newsletter

Subscribe to the Simmer newsletter to get the latest news and content from Simo Ahava right in your inbox!

How it works

The Google Tag Manager: Web Container The client template comes pre-integrated into the server containers. To activate it, you need to create a new client with it.

go to the customers in the Google Tag Manager UI and click to create a new client.

New customer

tap on Client configuration box to open selected. find Google Tag Manager: Web Container Customer template, and click to choose it.

GTME Web Container

To configure the client, you basically need to list the Google Tag Manager container identifiers It must be authorized by this client.

To add a new ID, simply click add container idand add it to the list.

Ago Allowed container identifiers The field can take variables too, you could theoretically create a variable that fetches the container id from the request URL directly (ie anything after ?id= in a https://server-container.com/gtm.js?id=GTM-ABCDEFG). However, I think it’s a good idea not to create a system like this to avoid spamming the endpoint with container requests that have nothing to do with your setup.

GTM ID in the client

Once Memorizes This client, server container is now enabled to respond to Google Tag Manager web container requests. A normal request for a web container would look like this:

https://www.googletagmanager.com/gtm.js?id=GTM-ABCDEFG

With the client you configured, you can now issue the request like this:

https://your.server.container.com/gtm.js?ID=GTM-ABCDEFG

The server-side endpoint will return the Google Tag Manager library in exactly the same format as the regular snippet, with the difference that it is given by is yours Endpoint and not a CDN from Google.

Update the snippet

You will of course need to update the Google Tag Manager container snippet as a result.

note! The update below applies to environments as well, as the new client template is designed to work with environments as well.

This is what a Google Tag Manager container snippet looks like:

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i)w[l]=w[l])(window,document,'script','dataLayer','GTM-PZ7GMV9');</script>
<!-- End Google Tag Manager -->

Need to change the string 'https://www.googletagmanager.com/gtm.js?id=' to correspond to the domain you created for the server side endpoint. If your container serves from https://sgtm.simoahava.com, the updated snippet would look like this:

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i))(window,document,'script','dataLayer','GTM-PZ7GMV9');</script>
<!-- End Google Tag Manager -->

Once the snippet is updated, you can take the server container into debug mode and see if it responds to requests for the GTM container:

The patch responds

You also need to check where to order a file gtm.js The library is sent using your browser’s network tools:

Network Tools

And, of course, make sure all your tags are working as they should with whatever debugging tools you have at your disposal.

Things to note

Currently, area containers will continue to be loaded from googletagmanager.com, but this will probably be fixed soon to load them also from the server side endpoint.

When you choose a Google Tag Manager container service from your first-party domain And Also sending data to Universal Analytics and/or GA4 client, you need to make sure that gtag tracks in these clients. This is because once you go to load the Google Tag Manager container from the first party domain, ie gtag.js Libraries that are loaded via this container will Moreover You need to download them from your first party domain. So be sure to check the relevant options if you are using these two clients.

note! If you want to authorize a file analytics.js A library from your server side domain, you should Moreover check the gtag tracks option and add UA-XXXXX-Y to the list. This setting also applies to that library.

Universal Analytics Client Paths

GA4 Client Paths

The last thing to note is that the file <noscript> The snippet can also be modified to load an iframe from the first-party endpoint. The only caveat is that the HTML page in an iframe will still load elements from googletagmanager.com.

In case you were wondering, Yes: The search console validation will work with the new first party <noscript> excerpt as well!

summary

Even though you don’t do it at all You have To use a web container when working with server-side tagging, I think many people do and will continue to do so because of the ease that Google Tag Manager provides for tagging a website.

The ability to delegate a Google Tag Manager container offers clear advantages for moving third-party scripts into a first-party context.

you of course Technically They still download the vendor’s JavaScript from their CDN. However, this download occurs in the server container, and the browser will only be specific to the request response path with the server container and not the resource endpoint itself.

Delivering the Google Tag Manager container agent to the server container may have an impact on the costs associated with setting up the tags on the server side, so be sure to keep an eye on billing in your Google Cloud Platform dashboard.

Let me know in the comments what you think of this new addition to the client mix built into server-side tagging!



Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button