The Persist Data Value extension is used to set a value into a persistent cookie. Choose the cookie name and persistence duration.

See the full list of available extensions.

In this article:

Table of Contents Placeholder

Prerequisites

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.

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.

Each cookie you set must be created as a data layer variable. Before you begin, read about how to create cookie variables in your data layer.

Using the Extension

Before you begin, familiarize yourself with how extensions work.

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 utag_main_<name>, where <name> is the name of your cookie. Learn more about Tealium cookies.

Example

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:

  1. Add the Persist Data Values extension.
  2. From the Persist drop-down list, select "Variable" and then select the variable city_state_zip (js).
  3. Set the Duration to "Session".
  4. Set Update to "Allow Update on Page View".
  5. In the Store in Cookie field, click the + button to create the variable utag_main_location .

Adding_Cookie_Value.png usage_example.png