Saturday, November 25, 2023
HomeTechnologyHow to use multiple Google Tag Managers on one site!

How to use multiple Google Tag Managers on one site!

It’s been a long time since Google Tag Manager was released, and the keyword “tag management” has become popular. SEM Technology has been investigating the number of Google Tag Manager implementations until December 2020, and the number of implementations is about 45% of listed companies.

Such Google Tag Manager, but in fact, with the default installation method, if you try to install two or more Google Tag Managers on the same site, unintended behavior may occur.

I managed to do this and tried trial and error to see if I could put multiple Google Tag Managers.


Advantages of installing multiple Google Tag Managers on one site

The advantage of having multiple Google Tag Managers is

  • running a corporate website
  • The website itself is organized by department in each directory

It appears in such cases. In such a situation,

  • Include a common Google Tag Manager for the entire site
  • Have a separate Google Tag Manager for each department in their own department directory only

by doing

  • Site common tags can be introduced to the site without hassle
  • Tags that you want to use only in a specific department can be introduced without affecting Google Tag Manager in other departments.
  • There is no fear of updating tags that conflict with those of other departments (change history is divided)

be able to benefit from.

on the other hand,

  • I accidentally set the same tag from two Google Tag Managers.
  • It took a lot of time to investigate problems with the tags installed on the site.

There are some disadvantages.

How to install multiple Google Tag Managers on one site

Introduction

Let’s assume that one website is managed by members of multiple departments. For site administrators,

  • Administrator of the entire site (Mr. A)
  • Administrator of the directory under /section-A/ (Mr. B)
  • Manager of the directory under /section-B/ (Mr. C)
  • Administrator of directories other than /section-A/ and /section-B/ (Mr. D)

Suppose there is

Creating a common container for the entire site

First, create a common Google Tag Manager container for the entire site. For this container, issue a tag and introduce it to the entire website in the same way as the usual tag manager installation method. This container will allow the “site-wide administrator” (Mr. A) to have permissions.

Create a container for each department

Next, create as many Google Tag Manager containers for each department as you need. In other words, create a total of three containers for Mr. B, Mr. C, and Mr. D. These permissions should be held by Mr. B, Mr. C, and Mr. D respectively. In addition, it would be good to have Mr. A, who is the administrator of the entire site, also have authority if necessary. Also, I think it’s a good idea to create all containers under the same account.

Create a “regular expression table” that converts the page path to the corresponding GTM container ID

Based on the page path, create a variable that acquires the GTM container ID using the “regular expression table”. Before regular expression tables, it would have required a little more work, but now that regular expression tables are here, it’s a simple setup.

The settings are as follows. The variable name is “Child GTM Container ID” and the following story is progressing. You can also create it with a different variable name, but please read accordingly in the following.

For those who are not confident in regular expressions, I also explain it in the book “Introduction to Technology for Digital Marketers” published in October 2020, so it would be a good idea to buy it and study it.

Of course, in the GTM-BBBBBB, GTM-CCCCCC, GTM-DDDDDD parts, enter the container ID of each GTM you created. Also, set section-A and section-B according to your own site.

Install a second GTM using these variables

The second Google Tag Manager will deliver using the “custom HTML” of the first Google Tag Manager. The tag to be delivered is based on the tag used to install Google Tag Manager. However, you can ignore tags in environments where JavaScript does not work.

The custom HTML to be delivered is as follows. Of the tag manager standard snippets, the part corresponding to the container ID refers to the GTM variable.

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{Child GTM Container ID}}');</script>
<!-- End Google Tag Manager -->

If this HTML tag is set to fire on all pages, the implementation is complete. Of course, it is also possible to narrow down to deliver only specific pages with triggers.

Supplement: About changing data layer variables

Google Tag Manager Developer Help Page – How to install multiple Google Tag Managers on one page (one site) in the form of Multiple Containers on a Page in Google Tag Manager for Web Tracking.

In the past, it was necessary to change the variable name and put it on the site so that the tag manager data layer variable name would not be duplicated. There is no problem if you install . If you do not want to share the internal data layer variable name, please change the data layer variable name as follows and install it.

<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5K253H"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayerSecond','{{Child GTM Container ID}}');</script>
<!-- End Google Tag Manager -->

summary

I thought you could only have one Google Tag Manager per site, but technically you can have two or three as many as you want (although there’s no advantage to having so many). If you change the data layer variable name and install it on the site, be careful not to forget to change the variable name when using the dataLayer variable in JavaScript etc.

RELATED ARTICLES

What is StyleGAN?

Leave a reply

Please enter your comment!
Please enter your name here

Recent Posts

Popular Posts

Most Popular

Recent Comments