A variable is a placeholder used in a condition or tag. For example, the Element Text variable is used to obtain the text content of the target DOM element in a web app.
The variable functions as follows:
DTM provides preset variables which can be used to configure most tags and conditions. If preset variables cannot meet your requirements, you can also create your own custom variables. Currently, DTM provides 30 types of preset variables and 13 types of custom variables.
Category |
Variable |
Description |
|---|---|---|
Utilities |
Config ID |
ID of the current configuration. |
Config Version |
Version number of the current configuration. |
|
Event |
Name of a triggered event. |
|
Random Number |
Random number. The value range is [0, 2147483647). |
|
Undefined Value |
Undefined value. NOTE:
|
|
Page element |
Element |
When a condition of the Click > All elements, Click > Link only, or Form submission type is triggered, the reference of the target DOM element is obtained using the element_ key in the recordTier. |
Element Classes |
When a condition of the Click > All elements, Click > Link only, or Form submission type is triggered, the class of the target DOM element is obtained using the elementClasses_ key in the recordTier. |
|
Element ID |
When a condition of the Click > All elements, Click > Link only, or Form submission type is triggered, the ID of the target DOM element is obtained using the elementId_ key in the recordTier. |
|
Element Target |
When a condition of the Click > All elements, Click > Link only, or Form submission type is triggered, the reference of the target object of the target DOM element is obtained using the elementTarget_ key in the recordTier. |
|
Element Text |
When a condition of the Click > All elements, Click > Link only, or Form submission type is triggered, the text content of the target DOM element is obtained using the elementText_ key in the recordTier. |
|
Element Type |
When a condition of the Click > All elements, Click > Link only, or Form submission type is triggered, the label type of the target DOM element is obtained using the elementType_ key in the recordTier. |
|
Element URL |
When a condition of the Click > All elements, Click > Link only, or Form submission type is triggered, the URL of the target DOM element is obtained using the elementUrl_ key in the recordTier. |
|
Error |
Error Line |
When a condition of the JavaScript error type is triggered, the number of the line where the error occurred is obtained using the errorLine_ key in the recordTier. |
Error Message |
When a condition of the JavaScript error type is triggered, the error message is obtained using the errorMessage_ key in the recordTier. |
|
Error URL |
When a condition of the JavaScript error type is triggered, the error URL is obtained using the errorUrl_ key in the recordTier. |
|
Preview Mode |
This variable is used to obtain the preview mode status. The value true will be returned if the preview mode is enabled, and the value false will be returned if the preview mode is disabled. |
|
History |
History Source |
When a condition of the History change type is triggered, the history source is obtained using the historySource_ key in the recordTier. |
New History Fragment |
When a condition of the History change type is triggered, the URL segment (a string after #) after history change is obtained using the newHistoryFragment_ key in the recordTier. |
|
New History State |
When a condition of the History change type is triggered, the status object that triggers the history change is obtained using the newHistoryState_ key in the recordTier. |
|
Old History Fragment |
When a condition of the History change type is triggered, the URL segment (a string after #) before history change is obtained using the oldHistoryFragment_ key in the recordTier. |
|
Old History State |
When a condition of the History change type is triggered, the active status object before history change is obtained using the oldHistoryState_ key in the recordTier. |
|
Web page |
Page Hostname |
Host name of the current web page. |
Page Path |
Path in the current URL. |
|
Page URL |
Complete URL of the current web page. |
|
Referrer |
Referrer URL of the current web page. |
|
Scroll |
Scroll Depth Threshold |
When a condition of the Scroll depth type is triggered, the scroll depth threshold is obtained using the scrollDepthThreshold_ key in the recordTier. If the unit is percent, the threshold is a number ranging from 0 to 100. If the unit is pixels, the threshold is the number of pixels. |
Scroll Depth Units |
When a condition of the Scroll depth type is triggered, the scroll depth unit is obtained using the scrollDepthUnits_ key in the recordTier. The value is percent (percentage) or pixels (number of pixels). |
|
Scroll Direction |
When a condition of the Scroll depth type is triggered, the direction of the scroll depth is obtained using the scrollDirection_ key in the recordTier. The value is vert (vertical) or horiz (horizontal). |
|
Visibility |
Visible Duration |
When a condition of the Element visibility type is triggered, the visible duration of the target element is obtained using the visibleDuration_ key in the recordTier. |
Visible Ratio |
When a condition of the Element visibility type is triggered, the visible percentage of the target element on this page is obtained using the actualScreenRatio_ key in the recordTier. |
Category |
Variable |
Description |
|---|---|---|
Web page |
Custom JavaScript |
JavaScript method with a return value. The custom variable value will be returned when the method is executed successfully. If the function fails to be executed or no return value is defined, the value of the custom variable is undefined. It is recommended that the function exclude keywords like eval, with, and Function. |
This variable is used to obtain the first-party cookie value of the current network domain. |
||
JavaScript |
This variable is used to obtain the value of a global JavaScript variable. |
|
Key in the recordTier, which identifies a custom variable. The recordTier variable is the key, and the recordTier is a list of key-value pairs. recordTier variables can be referenced by tags, conditions, and other variables. For details, please refer to recordTier Variable. |
||
Page element |
This variable is used to obtain the text or specified attribute value of the target DOM element. |
|
This variable is used to extract attributes of elements related to the trigger condition (click or form submission). |
||
This variable is used to obtain the visibility status of a target element. It has two types of values:
|
||
Others |
Common parameters of Google Analytics, which facilitates reference by multiple tracker tags. All fields in the variable will be passed to tags of Google Analytics as parameters. |
|
Utilities |
A group of key-value pairs used to match with the selected variable. If a key in the regular expression table matches with the selected variable, the value of the key will be used as the variable value. |
|
Constant |
This variable is used to set a fixed value. |
|
A group of key-value pairs used to match with the selected variable. If a key in the mapping table matches with the selected variable, the value of the key will be used as the variable value. |
||
URL |
URL components. This variable takes the URL of the current web page (obtained through document.location) as an input parameter. URL components include the complete URL, protocol, host name, port number, path, file name extension, and parameter. |
|
URL components. It takes the URL of the previous web page (obtained through document.referrer) as an input parameter. URL components include the complete URL, protocol, host name, port number, path, file name extension, and parameter. |