document.title β GTM Variable Template for GTM
document.title CORE GTM
Returns the current page title from the document. This function retrieves the title tag content of the current page.
When to Use This
Section titled βWhen to Use ThisβGTM Utilities
Access GTM-specific APIs: dataLayer, debug mode, container settings.
GTM Configuration
Section titled βGTM ConfigurationβThis is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
Read-only Preview
document.title
This function takes no parameters.
Result Handling
Output Function (optional)
βοΈ Optional function to apply to the result before returning it (e.g., str => str.toLowerCase() for lowercase, str => str.substring(0, 50) to truncate). Useful for chaining transformations on the output.
Related Variables
Section titled βRelated VariablesβSame category: GTM
Under the Hood
Section titled βUnder the Hoodβπ View Implementation Code
/** * Returns the page title. * * @param {Function|string} [data.out] - Optional output handler: function to transform result or string with format. * * @returns {string|null} The page title, or null if not found. * * @framework ggLowCodeGTMKit */const readTitle = require('readTitle');
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;const out = safeFunction(data.out);// ===============================================================================// getPageTitle - Direct mode// ===============================================================================return out(readTitle());
___WEB_PERMISSIONS___
[ { "instance": { "key": { "publicId": "read_title", "versionId": "1" }, "param": [] }, "isRequired": true }]