<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Florian Flock on Medium]]></title>
        <description><![CDATA[Stories by Florian Flock on Medium]]></description>
        <link>https://medium.com/@floflock?source=rss-9528c77ef185------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*oiBLXlhPB-mf2SFpFPEUTw.jpeg</url>
            <title>Stories by Florian Flock on Medium</title>
            <link>https://medium.com/@floflock?source=rss-9528c77ef185------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 18:17:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@floflock/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using Google Tag Manager in a multi-domain setup]]></title>
            <link>https://medium.com/@floflock/using-google-tag-manager-in-a-multi-domain-setup-d472ec6a4ec?source=rss-9528c77ef185------2</link>
            <guid isPermaLink="false">https://medium.com/p/d472ec6a4ec</guid>
            <category><![CDATA[google-analytics]]></category>
            <category><![CDATA[tracking-user-activity]]></category>
            <category><![CDATA[tracking]]></category>
            <category><![CDATA[google-tag-manager]]></category>
            <category><![CDATA[website-development]]></category>
            <dc:creator><![CDATA[Florian Flock]]></dc:creator>
            <pubDate>Sun, 30 Jun 2019 18:55:14 GMT</pubDate>
            <atom:updated>2019-07-01T06:41:58.178Z</atom:updated>
            <content:encoded><![CDATA[<p>Google Tag Manager became more and more popular in the last couple of months. The overall recommendation on many insider blogs is to outsource all tracking activities to Google Tag Manager, including Analytics, Facebook Pixel etc. But what if your page has multiple domains, multiple languages and — for e-commerce websites — various currencies?</p><p>We thought about that too, because our e-commerce infrastructure provides over 40 online shops with more than 400 domains. Therefore, the average online shop has about ten languages, and each language has its domain. However, tracking is facing a lot of complexity because of that fact. Sounds like a large project migrating from on page tracking to Google Tag Manager, but we made it perfectly.</p><p>I want to demonstrate with the following Google Analytics example.</p><h4>How do we gather data?</h4><p>Millions of users hit our online shops every week. We use Google Analytics for general purposes, also Facebook Pixel and Google Ads Conversion Pixel on every single domain. Besides, there are some other essential tracking scripts like Hotjar, some affiliate scripts and price comparison platforms. The implementation of all scripts are very detailed, and we try to use as many features as possible to get the most out of the tracking. But in general, we saw that all tracking scripts need the same data — another good reason to migrate to Google Tag Manager.</p><p>Our infrastructure grew potentially in the last year, and tracking was done on the very traditional way: on page script implementation. Behind the delivered HTML for the user’s web browser, there is a PHP tech stack under the hood. Anyway, tracking could be controlled very well this way. Because of browser developments (<a href="https://webkit.org/blog/8311/intelligent-tracking-prevention-2-0/">ITP 2.0</a>), we decided to migrate the full tracking to Google Tag Manager Container, facing the main problem of this article: complexity due to multiple domains, languages and currencies.</p><h4>Container structure</h4><p>There are lots of ways to integrate Google Tag Manager into the online shops. We decided to create one container per online shop brand. The result of this decision is that you have to handle multiple domains in one container. Every language domain from the same shop brand has the same container. In case of different Analytics account on each domain, the container has to handle this for now on. Our structure is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*khVgKZLVSGrd2-f1ISYe0g.png" /></figure><h4>First step: DataLayer definition</h4><p>When we talk about Google Tag Manager, we should first talk about DataLayer. As known, it is our middleware transporting data from our webpage to Google Tag Manager. So basically, a third of the concept was defining the DataLayer in a way that every tracking script can use the needed data. To keep the DataLayer clean and structured, we wrote down some basic rules:</p><ul><li>We follow the <a href="https://google.github.io/styleguide/jsoncstyleguide.xml">Google JSON Style Guides</a> for all DataLayer purposes. To be consistent, the naming is also used on tags, triggers and variables in Google Tag Manager.</li><li>Every push to the DataLayer becomes an event name.</li><li>Every event name is namespaced, e.g. <em>eec</em> for Enhanced E-commerce or <em>general</em> for general events.</li><li>Keep JSON objects as general as possible by using no tracking script names.</li><li>We primarily use our self-defined events and trigger on that.</li></ul><p>Following the rules, we made an overview of needed DataLayer pushes, and we also defined the specific objective to every push.</p><p>We added two main events to our page to configure Google Analytics and all other scripts, which need the information about currency, language and domain in the tracking. One of the main events we use is ‘general.initialize’. This event is rendered in the head on every single page hit right after array initialisation. As you can see below, the event delivers much useful information about the page hit, including domain, language, currency and also targeted country. By the way, we set the country by the domain, not programmatically by the browser language etc.</p><pre>&lt;script&gt;<br>window.dataLayer = window.dataLayer || [];<br>window.dataLayer.push({<br>    &quot;event&quot;: &quot;general.initialize&quot;,<br>    &quot;general&quot;: {<br>        &quot;domain&quot;: &quot;domain_de&quot;,<br>        &quot;language&quot;: &quot;de&quot;,<br>        &quot;country&quot;: &quot;DE&quot;,<br>        &quot;currencyCode&quot;: &quot;EUR&quot;,<br>        &quot;version&quot;: &quot;2019.6.118.100&quot;,<br>        &quot;server&quot;: &quot;frontend02&quot;<br>    }<br>});<br>&lt;/script&gt;</pre><p>Because of some speed optimisations, we cannot target some information about the page in the head. The head is flushed while the server renders the body. Therefore, at the very end of the delivered HTML, we add another event to our DataLayer for information we only know in the footer.</p><pre>&lt;script&gt;<br>window.dataLayer.push({<br>    &quot;event&quot;: &quot;general.ready&quot;,<br>    &quot;general&quot;: {<br>        &quot;device&quot;: &quot;desktop&quot;,<br>        &quot;path&quot;: &quot;/some-page?pagination=2&quot;,<br>        &quot;canonicalPath&quot;: &quot;/some-page&quot;,<br>        &quot;pageType&quot;: &quot;category&quot;<br>    }<br>});<br>&lt;/script&gt;</pre><p>There are a couple more events we push to Google Tag Manager, but these to events are crucial for the basic tracking script configuration.</p><h4>Second step: Configure variables</h4><p>In this step, you should define the information above as variables in Google Tag Manager to have universal access to that. In the screenshot below, you can see how our variables are named. For example, the domain is named as ‘generalDomain’, because the information comes from a general event and contains the domain. For now on, the variable name is self-explanatory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnbwLGQmiRfI5ZZ2e6ftww.png" /></figure><p>Originating that this specific domain has its own Analytics Account, we can react on this variable and set the right tracking ID. This challenge can be solved by using a ‘lookup table’ in Google Tag Manager. This feature is a variable type which gets input and converts it to a specific output from a table. As you can see in my screenshot below, the input variable is our ‘generalDomain’. In case of a page hit, the frontend sets the domain in the DataLayer initialisation, and the outcome here is a Google Analytics tracking ID for the specific domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fanDntGd2kR10cCy2rfh-g.png" /></figure><p>Google Analytics configured via Google Tag Manager uses a specific pre-defined variable. It is called ‘Google Analytics settings’. The screenshot shows that the tracking id contains our defined variable from above. If you deal with transactions in Google Analytics — an that is the typical case for online shops — you can also specify the currency code in this variable following the same logic as described.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tW7RVb47TqNhM6eQYDaQlA.png" /></figure><h4>Third step: Create the trigger</h4><p>Be aware of your triggers, especially the pre-defined ‘Page View’ trigger, which is coming from Tag Manager automatically. If you follow the steps below, it is necessary to check, when you push our data into the DataLayer. The ‘Page View’ trigger fires right after the Tag Manager tracking scripts. If the Tag Manager is implemented like recommended, the ‘Page View’ trigger fires in the head.</p><p>We wanted to be independent of the standard trigger structure and use only our events as triggers. The screenshot shows a trigger which we use for a typical page view event in Google Analytics or Facebook Pixel. The important thing is that our main tracking scripts are fired in the footer because the ‘general.ready’-event is pushed to DataLayer in the very last lines of our HTML source code. Maybe, it is not mandatory, but on our infrastructure, we cannot be sure that all information is present in the head because of the header flush. Using the ‘general.ready’-event is the safe way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kOsxN1s12di2Ouk6BOepA.png" /></figure><p>As you can see below, there is a clear structure of how the events have been fired. The event ‘general-initialize’ is always the first event. It could be used to setup up general things for tracking. We use this event to implement the general Facebook Pixel but without events. Also ‘adsConversionLinker’ is present there. Our main event is ‘general.ready’ because all necessary information is present there and a page view can be fired then. As described, we do not use pre-defined ‘Page View’ coming from Tag Manager initialisation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*G3f_cdHs9GTsXw32VM_DBg.png" /></figure><h4>Fourth step: Create the tag</h4><p>The last step is simple. Because of the present domain information, you can efficiently react to this in every tag. The screenshot below shows a Google Analytics page view tag using the variables from above and the defined trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a2ShFgIitS1wjcACbm9ETg.png" /></figure><h4>Conclusion</h4><p>We solved a common issue which is not described in general and reached all the goals we set. Especially the reduction of the number of containers keeps the maintainability high and let us react fast to changes. The marketing team is also more independent of the development and implementation of our online shop infrastructure.</p><p>The information from the shown DataLayer push events is heavily used in our tracking setup. Some tracking scripts are only active on a specific page type. All in all, our Tag Manager container became more reactive because of the implementation of general data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d472ec6a4ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>