Linked variables¶
The value of variables can be dependent on where an event occured or what type of event occured. Usually, when the where or what is relevant, we will create a tracking component.
Let’s say we have the following subdomains:
https://www.graindataconsultants.com (Production) https://staging.graindataconsultants.com (Staging) https://test.graindataconsultants.com (Test)
We already have defined the above domains as matching domains, because we use a different Google Analytics UA-code for each domain. Besides that we would like to add the environment an event occurede on (production, staging, test). we can solve this in two ways:
- Add environment in the datalayer
For more information about our tracking code, read the tracking code documentation.
In this option, the developer needs to add the information.
- Add a variable link to domains
IMAGE REPLACEMENT: EXAMPLE VARIABLE LINK
In this case you will tell Harvest you want to have the value of production to be assigned to the variable pageData.environment whenever this specific domain is matched.
Another example might be related to custom metrics in Google Analytics. Let’s say you want to count with a custom metric anytime someone clicked the download app button. To do this, we would need a variable that will hold the value 1 anytime this occurs and map this to the custom metric specified in Google Analytics.
Again there are 2 options:
- Add environment in the datalayer
In this scenario, the developer needs to add the variable with value 1 which we will map to the custom metric.
- Add a variable link to a content interaction
IMAGE REPLACEMENT: EXAMPLE VARIABLE LINK
As you can imagine, enriching variables and linking them to tracking components gives you a lot of flexibility.