Skip to content

Variables

Inhalt
Capture dynamic content using variables Cookie variable Data layer variable URL variable DOM variable Constant variable Custom variable Web storage variable Use variables

Capture dynamic content using variables

A tag can be used to record or transmit not only fixed values, but also dynamic information from the website. Content from cookies, the data layer, DOM elements or URL parameters can serve as sources. In the following, we explain how the individual tag types are filled and then used.

To configure variables, click on tag manager in the menu and select the sub-item My variables. All existing variables are displayed in the overview. The action options for editing, deleting or copying the selected variable appear on mouseover.

Screenshot overview of the variables in the etracker tag manager

Via Edit, you can see directly in which tags and triggers the selected variable is used.

Screenshot in which tags and triggers the variable is used

To create a new variable, either copy an existing variable or click on + Add variable.

Add screenshot variable in etracker tag manager

Cookie variable

Use the cookie variable to use cookie values for filling tag parameters. In addition to a name for the variable, all you need to do is enter the cookie name.

Set up cookie variable in etracker tag manager

Data layer variable

Datalayer variables can be used to read out datalayers from a wide range of providers. To do this, enter the name of the data layer and the name of the corresponding variable and assign a name for the variable.

Set up data layer variable in etracker tag manager

URL variable

Two options are available for the URL variable: GET parameter and Query. If GET parameter is selected, the value of a specific GET parameter can be used. To do this, simply enter the name of the desired GET parameter. If Query is selected, all content contained after the question mark is taken from the URL.

Set up URL variable in etracker tag manager

DOM variable

For DOM variables, the element from which the value is to be obtained must first be specified. This is done using the usual selection between CSS selector, element ID and element class.

Set up DOM variable in etracker tag manager

You can then define whether the variable should be filled with the text of this element or whether the value of an attribute from this element should be used. If attribute value is selected, the attribute name must be specified. This also makes it possible to read so-called “data-attributes”.

Constant variable

This is not a dynamic variable. Rather, it simplifies the reuse of information in any number of tags. This is practical, for example, for account data and access keys that are used for identification with third-party services.

Custom variable

The custom variable makes it possible to calculate and output values based on JavaScript code using any function. This allows variable values to be defined that are not available as templates. It offers a great deal of flexibility, as even complex logic is possible by extracting certain information from the DOM, performing calculations, combining different information and returning it.

Examples are the output of the timestamp, the retrieval of a form field value, currency conversions and the generation of random values.

Screenshot Set up custom variable

Web storage variable

The Web Storage variable makes it possible to pass on information from the Session or Local Storage.

Screenshot of setting up the web storage variable in the etracker tag manager

Use variables

To use a variable in a tag, the variable must be selected in the appropriate parameter of the corresponding tag. In addition to fixed designations, integrated variables are available for selection that refer to the value from the element to which the trigger relates. You can also use your own variables, which can be filled from the four sources mentioned above and are dependent on the selected trigger.

How to use the variables set up