Update time: January 14, 2025
Built-In Variables are one of the core features of Google Tag Manager (GTM). They provide quick access to commonly used information—such as the current page URL, click details, form data, scroll depth, and video interactions—without requiring any custom configuration.
Unlike User-Defined Variables, which you create manually, Built-In Variables are provided by GTM. Simply enable the variables you need, and they’re ready to use throughout your GTM container.
Whether you’re implementing Google Analytics 4 (GA4), Google Ads, Meta Pixel, or other marketing tags, Built-In Variables help you create more flexible triggers, capture dynamic values, and simplify your tracking setup.
In this guide, you’ll learn:
- What Built-In Variables are
- How to enable Built-In Variables
- Every Built-In Variable category available in Web containers
- Common use cases for each category
- Best practices for using Built-In Variables
What Are Built-In Variables?
Built-In Variables are pre-configured variables provided by GTM. They expose commonly used information from your website, browser, or Data Layer without requiring any additional configuration.
Unlike User-Defined Variables, Built-In Variables cannot be edited or customized. Instead, you simply enable the variables you need and use them in your tags, triggers, and other variables.
Built-In Variables can retrieve information such as:
- Current page URL
- Referrer URL
- Clicked element
Because they are maintained by Google, Built-In Variables are the recommended choice whenever they provide the data you need.
Built-In Variables vs. User-Defined Variables
Although both types of variables are used throughout GTM. they serve different purposes.
| Built-In Variables | User-Defined Variables |
|---|---|
| Created by GTM | Created manually by the user |
| Only need to be enabled | Must be configured |
| Cannot be customized | Fully customizable |
| Best for common tracking values | Best for custom business logic |
| Minimal setup required | May require JavaScript, Data Layer, or custom configuration |
In practice, most GTM implementations use both Built-In Variables and User-Defined Variables together.
How to Enable Built-In Variables
Most Built-In Variables are disabled by default. Before you can use them, you’ll need to enable the ones required for your implementation.
To enable Built-In Variables: In GTM, click 「Variables」——「Configure」:
Check it to enable it. Once enabled, you can see it in Variable:
Once enabled, the selected variables become available throughout your GTM container and can be used in tags, triggers, and other variables.
Built-In Variables Categories
The available Built-In Variables depend on your container type, such as Web, Server, AMP, Android, or iOS.
This article focuses on Web containers, which currently include multiple Built-In Variable categories covering page information, user interactions, browser events, debugging, and Google Analytics identifiers.
The main categories include:
Pages Variables
URL Variables provide information about the current page URL and the page that referred the visitor to your website.
These variables are among the most frequently used in GTM because they allow you to build URL-based triggers, capture campaign parameters, and identify landing pages.
There are four URL-related Built-In Variables.
- Page Hostname: Returns the hostname (domain name) of the current page. eg:http://www.bbccss.com
- Page Path: Returns only the path portion of the current URL. eg:/google/google-analytics
- Page URL: Returns the complete URL of the current page. eg:https://www.bbccss.com/google/google-analytics
- Referrer: Returns the full URL of the page that brought the visitor to the current page. eg:https://www.google.com
Utilities Variables
Utility Variables provide useful information about your GTM container, Data Layer events, and debugging environment. They can also generate random values or support advanced tag sequencing.
There are six Utility Built-In Variables.
- Analytics Client ID : The unique identifier assigned to a browser or device.
- Analytics Session ID: The identifier for the current session.
- Analytics Session Number: The number of the current session for the user.
- Event: Returns the name of the current Data Layer event by reading the
eventkey from the Data Layer. - Environment Name: Returns the name of the current GTM environment.
- Container ID: Returns the public ID of the current GTM container.
- Container Version: Returns the published version number of the current GTM container.
- Random Number: Returns a randomly generated integer each time the variable is evaluated.
- HTML ID: Returns the unique ID assigned to a Custom HTML tag. This variable is primarily used with Tag Sequencing to determine whether a Custom HTML tag executed successfully.
Errors Variables
Error Variables capture information generated by the JavaScript Error Trigger. They help identify where JavaScript errors occur and what caused them.
There are four Error Built-In Variables.
- Error Message: Returns the JavaScript error message.
- Error URL: Returns the URL of the JavaScript file where the error occurred.
- Error Line: Returns the line number where the JavaScript error occurred.
- Debug Mode: Returns true when GTM Preview Mode is enabled. false when GTM is running normally.
Clicks Variables
Click Variables provide information about the element a visitor clicks. They are available only when using Click Triggers.
There are six Click Built-In Variables.
- Click Element: Returns the DOM element that was clicked.
- Click Classes: Returns the value of the clicked element’s
classattribute. Example: de - Click ID: Returns the value of the clicked element’s
idattribute. Example: ad - Click Target: Returns the value of the clicked element’s target attribute
- Click URL: Returns the destination URL of the clicked link. Example: https://www.bbccss.com/contact-me
- Click Text: Returns the visible text of the clicked element. Example: Contact Me
Forms Variables
Form Variables provide information about submitted HTML forms. They are available only when using the Form Submission Trigger.
There are six Form Built-In Variables.
- Form Classes: Returns the value of the form’s
classattribute. - Form Element: Returns the DOM element of the submitted form.
- Form ID: Returns the value of the form’s
idattribute. - Form Target: Returns the value of the form’s
targetattribute. - Form Text: Returns the visible text contained within the submitted form.
- Form URL: Returns the URL associated with the submitted form.
The Form Submission Trigger works only when the following conditions are met:
- The page contains a standard HTML
<form>element. - The form includes a submit control, such as:
<input type="submit"><button type="submit">
If a website submits forms entirely through JavaScript without using a standard HTML form element, the Form Submission Trigger may not work. In this case, consider using a Click Trigger or a custom Data Layer event instead.
History Variable
History Variables provide information about changes to the browser’s history state. They are designed to work with the History Change Trigger and are primarily used for tracking Single Page Applications (SPAs) built with frameworks such as React, Angular, and Vue.
There are five History Built-In Variables.
- History Source: Returns the event that caused the history change.
- New History Fragment: Returns the fragment (hash) portion of the URL after the history change. Example:#pricing
- New History State: Returns the new History State object created by the website.
- Old History Fragment: Returns the URL fragment before the history change.
- Old History State: Returns the History State object before the navigation occurred.
Videos Variables
Video Variables capture information about embedded YouTube videos. They work together with the YouTube Video Trigger to measure video engagement.
There are eight Video Built-In Variables.
- Video Current Time: Returns the playback position (in seconds) when the event occurs.
- Video Duration: Returns the total duration of the video in seconds.
- Video Percent: Returns the percentage of the video that has been watched. Possible values range from 0 to 100.
- Video Provider: Returns the video provider. Example:YouTube
- Video Status: Returns the current playback state.
- Video Title: Returns the title of the YouTube video.
- Video URL: Returns the URL of the YouTube video. Example: https://www.youtube.com/watch?v=xxxxxxxxxxx
- Video Visible: Returns true if the video is visible in the browser viewport. false if the video is outside the viewport or the browser tab is inactive.
Scrolling Variables
Scroll Variables provide information about how far visitors scroll on a page. They work together with the Scroll Depth Trigger.
There are three Scroll Built-In Variables.
- Scroll Depth Threshold: Depending on your trigger configuration, the value may represent: A percentage (0–100) A pixel value
- Scroll Depth Units: Returns the measurement unit used by the trigger. Possible values include: percent pixels
- Scroll Direction: Returns the direction in which the user scrolled. Possible values include: vertical horizontal
Visibility Variables
Visibility Variables provide information about how much of an element is visible on the screen. They work with the Element Visibility Trigger.
There are two Visibility Built-In Variables.
- Percent Visible: Returns the percentage of the selected element that is visible when the trigger fires. Possible values range from 0 to 100.
- On-Screen Duration: Returns how long the selected element has remained visible before the trigger fires. The value is measured in milliseconds.
Best Practices
To get the most out of Built-In Variables in GTM, follow these best practices:
Enable Only the Variables You Need
Although enabling additional Built-In Variables has little impact on performance, it’s good practice to enable only the variables required for your implementation. This keeps your GTM workspace organized and easier to maintain.
Use Built-In Variables Whenever Possible
Built-In Variables are maintained by Google and are generally more reliable than custom JavaScript or DOM scraping.
Whenever a Built-In Variable provides the information you need, use it instead of creating a User-Defined Variable.
Choose the Most Appropriate Variable
Some variables are more stable than others.
For example:
- Prefer Click ID over Click Text, since button text may change.
- Prefer Page Path over Page URL if query parameters are not required.
- Prefer Data Layer Variables over DOM-based variables whenever possible.
Test Before Publishing
Always use GTM Preview Mode to verify that variables return the expected values before publishing your container.
Testing helps identify configuration issues before they affect your production environment.
Use Descriptive Names
When referencing Built-In Variables in triggers, tags, or documentation, use clear and descriptive names to make your GTM container easier to understand and maintain.
Frequently Asked Questions
Which Built-In Variables Should I Enable?
Enable only the variables required for your implementation.
For most websites, the following Built-In Variables are commonly used:
- Page URL
- Page Path
- Referrer
- Event
- Click Variables
- Form Variables
- Scroll Variables
Enable additional variables only when they are needed for your tracking requirements.
Can Built-In Variables Be Customized?
No. Built-In Variables are predefined by GTM and cannot be modified.
If you need custom logic or additional data, create a User-Defined Variable instead.
When Should I Use Built-In Variables Instead of User-Defined Variables?
Use Built-In Variables whenever they provide the information you need.
If the required data isn’t available through a Built-In Variable, create a User-Defined Variable to retrieve or calculate the value.
Summary
Built-In Variables are a fundamental part of every GTM implementation. They provide quick access to commonly used information without requiring custom code, making it easier to build reliable tags and triggers.
Whether you’re tracking page views, button clicks, form submissions, scroll depth, YouTube video engagement, or browser history changes, Built-In Variables simplify your tracking setup and reduce the need for custom JavaScript.
As your implementation becomes more advanced, Built-In Variables can be combined with User-Defined Variables, Data Layer Variables, and custom events to create flexible, scalable, and maintainable tracking solutions.
If you’re new to GTM, start by mastering Built-In Variables—they form the foundation for almost every GTM implementation.


