Search code examples
google-analyticsgoogle-tag-manageruniversal-analytics

How to implement environments between Google Tag Manager and Universal Analytics?


The goal is to have the Dev and Live env from Google Tag Manager map to Dev and Live environments on Universal Analytics.

About UA, from what I know, it doesn't have environments, so I would just create two properties, under Admin, each representing an environment.

Now, I've got to a point where I create the environments in Google Tag Manger. How do I proceed from here in order to link them to the appropriate UA properties?

enter image description here

If I'm taking a wrong approach, please steer me away.


Solution

  • Found my answer in this article.

    In short:

    1. Create your two (Dev, Prod) UA properties and note their Tracking Codes
    2. In the GTM console, save those Tracking Codes as constants
    3. Enable Environment Name Built-In Variable
    4. Create new Lookup Table Variable that outputs Tracking Code based on Environment Name
    5. Provide the Lookup Table Variable to the Universal Analytics tag