Skip to content

document.title — GTM Variable Template for GTM

VARIABLES › GTM
document.title CORE GTM

Returns the current page title from the document. This function retrieves the title tag content of the current page. ___________ ✏️ Example Current page title: "Welcome to My Website" Output: "Welcome to My Website"


When to Use This

GTM Utilities

Access GTM-specific APIs: dataLayer, debug mode, container settings.


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.


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
  }
]