- TLC Home Home
- Discussions & Ideas Discussions & Ideas
- Product Guides Product Guides
- Knowledge Base Knowledge Base
- Developer Docs Developer Docs
- Education Education
- Blog TLC Blog
- Support Desk Support Desk
You want to change the value of a data source you are mapping to a tag based on the environment it is in. For example, you want to change the Account ID sent to Google Analytics based on the environment the tag is pushed to.
You will make use of ut.env, which is the built-in variable for publish environment and only available to utag v4.36 and above. Here's how to go about it:
Step 1: Add 'ut.env' as a Data Source.
Step 2: Create a lookup table Extension to set the various values of the Data Layer variable you want to change. Set Lookup Value In to ut.env.
Then map the destination to the Data Layer variable you wish to manage.
We are updating variable "ga_account_id_standard". We have three separate accounts, one for each environment. So we've added the Lookup Match for the dev, qa and the prod environments and then set the value we want for the Google Account ID for that environment in the Output fields.
Step 3: Map your Data Layer variable in the appropriate tag.
For this example, we're mapping the "ga_account_id_standard" Data Layer variable to the "Account" destination in Google Analytics.
Step 4: Save/Publish your profile.
You will make use of Tealium's configuration parameter, utag.cfg, to determine the environment loaded. Here's how to go about it:
Step 1 : Add a 'tealium_environment' and 'ga_account_id_standard' as Data Layer Variables.
Step 2: Set the value for 'tealium_environment' data source that is loaded
Add a Set Data Values extension and in the Configuration section set 'tealium_environment' to equal the following JavaScript Code:
utag.cfg.path.split('/')[6];
The logic will pull in the environment that Tealium is running on the page. Thus, if the page is loading the 'prod' environment then 'tealium_environment' will be set to 'prod'.
Step 3: Create a Lookup Table Extension to set the different values of the Data Layer variable you want to change
In this example, we are setting different Google Analytics Account IDs based on the environment. Here's an example of how that Lookup Table would be configured:
The order of the Set Data Values and the Lookup Table extensions is important. Ensure the Lookup Table extension runs AFTER the extension setting 'tealium_environment' to ensure a value is available to look up against! This is done by placing this extension lower, below the Set Data Values extension, within the extension list.
Step 4: Map your Data Source to the tag you want
For this example, we map the "ga_account_id_standard" Data Source to the "Account" destination in Google Analytics.
Step 5: Save and publish.
You're done! Everything should be working for you now!
The above steps can be applied to any Data Source variable you have in mind.
Copyright All Rights Reserved © 2008-2021