Data Layer
Learn how to manage data layer values across the app lifecycle.
How it works
To set global data layer values once instead of setting them in every tracking call, use the AddToDataLayer()
method. Data layer values added with this method are included in every tracked event, including lifecycle events. Set the expiry
parameter to the length of time to persist the value.
Learn more about data management.
Usage
To set data layer values, call AddToDataLayer()
with a data dictionary and an expiration parameter.
To learn more, see AddToDataLayer()
and Expiry
.
tealium.AddToDataLayer(new Dictionary<string, object>(1) {
{"user_language", "en-EN"}
},
Expiry.Forever
);
To get a data layer value, call GetFromDataLayer()
with the name of the value to retrieve.
string myString = (string)tealium.GetFromDataLayer("user_language");
This page was last updated: March 15, 2024