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.

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.

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.

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.

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.

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 include outputting the timestamp, retrieving a form field value, performing currency conversions and generating random values.

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.
