CDPGuidesSupport

Variables

Built-in and custom variables in the Ours Privacy Tag Manager, how to reference them, and how lookup tables and Custom JavaScript work.

Use this page to find the variable you need and reference it correctly. A variable reads a value from the page at the moment a tag or trigger runs. Use variables in trigger conditions and as event properties on tags.

The Variables list showing eight custom variables such as Clinic Location, Service Line, and Marketing Consent, with their types, folders, and last edited dates.

Built-in variables

Available in every container with no setup:

  • Page: Page URL, Page Path, Page Hostname, Page Title, Page Referrer.
  • Click: Click Element, Click Element URL, Click Element ID, Click Element Classes, Click Text. Set only while a click trigger is being handled.
  • Form, Scroll, Element Visibility, History Change, JavaScript Error: the same pattern for each interaction type, for example Form Element ID or Scroll Vertical Percentage.
  • Consent: Consent Type, Accepted Categories, Rejected Categories, Consent ID.

The full list appears in the variable picker in the app.


Custom variables

Create one when you need a specific value:

  • Click Data Attribute, Click HTML Attribute, Click URL: read from the clicked element.
  • URL, Path, Hostname, First Path Segment, URL Query Parameter, Referrer URL, Meta Content, SEO Canonical URL: read from the current page.
  • Data Layer: read a key from the data layer. Dot notation reaches nested values.
  • DOM Element: read an element's text or an input's value.
  • JavaScript Variable, Cookie, Local Storage, Session Storage, Constant.
  • Consent: Category: true when the category you pick is accepted. Use it in conditions to gate tags on consent.
  • Lookup Table and RegEx Table: map a source value to a label.
  • Custom JavaScript Function: a function that returns a value.

Lookup and RegEx tables

Both take another variable as input and return the output of the first matching row, or a fallback. Lookup Table matches exactly. RegEx Table matches patterns and supports $1 style replacements, so ^/providers/([^/]+)$ with output provider-$1 turns /providers/acme into provider-acme.

Custom JavaScript Function

Write a function body that returns the value. You can reference other variables inside it, and values keep their type:

function () {
  var clickedUrl = {{Click Element URL}};
  if (!clickedUrl) return undefined;
  return new URL(clickedUrl, window.location.href).hostname;
}

References inside quoted strings are not resolved. Concatenate instead: 'Clicked: ' + {{Click Element URL}}.


Referencing variables

Use double braces with the exact, case-sensitive name: {{Page URL}}, {{My Variable}}. A name that matches no variable is read from the data layer, so {{userTier}} works after dataLayer.push({ userTier: 'premium' }).


Next steps

  • Triggers: use variables in conditions.
  • Tags: send variables as event properties.
  • Recipes: lookup tables and consent gating in practice.

How is this guide?

On this page