The Persist Data Value extension is used to set a value into a persistent cookie. Choose the cookie name and persistence duration.
- utag v4.38 or higher. (See: How to upgrade utag.js)
- How extensions work
- Data Layer Variables: First Party Cookies
How it works
The Persist Data Value extension sets first-party cookies using custom text values or values from the data layer. Set the cookie to either the default Tealium cookie
utag_main, an existing first-party cookie, or a new one. Each cookie you set must also be created as a data layer variable.
The expiration of the cookie is based on the user’s session or a specified duration of time in hours or days. The cookie is either set once, updated on every page view, or set based on conditions that you define.
Using the extension
Once the extension is added, the following configuration options are available:
Persist: Select the value to save in the cookie:
- Text: Set the cookie value to the text you enter.
- Variable: Set the cookie to the value of a variable in the data layer.
Duration: Set the length of time that the data persists in the cookie.
- Session: The data remains in the cookie until the current visitor session ends.
- Visitor: The data remains in the cookie until the visitor deletes the cookie.
- Hours: The data remains in the cookie for the number of hours you specify.
- Days: The data remains in the cookie for the number of days you specify.
Update: Select when to replace or update the value.
- Allow Update on Page View: Every time the visitor views the page, the data is updated. The duration timer resets with each update.
- Keep First Value Set: Only the data from the first visit is saved. Subsequent visits do not alter this value.
Condition: Click Add Condition to specify when to run this extension. You may only add one condition.
Store in Cookie: Select the cookie variable to set. Click the + button to create a new one.
To store a value in the Tealium cookie, name the cookie variable in the format
<name> is the name of your cookie. Learn more about Tealium cookies.
Example: User location cookie
This example demonstrates how to persist the visitor’s location to a cookie. The location is retrieved from an existing data layer variable named
city_state_zip. This variable might only be available on one page, but the value is needed on all pages throughout the site, so the Persist Data Value extension is used to save it to a cookie that will last for the life of the session.
To create the location cookie:
- Add the Persist Data Values extension.
- From the Persist drop-down list, select Variable and then select the variable
- Set the Duration to Session.
- Set Update to Allow Update on Page View.
- In the Store in Cookie field, click the + button to create the variable
Thank you for your feedback!
This page was last updated: January 7, 2023