Hands-on module
Variables: read data on the page
Pull values out of the page and the URL so your tags have something to say.
Triggers decide when a tag runs; variables decide what it can say. This module is your first pass at reading data that's already present on the page and in the URL, no dataLayer required.
You'll switch on the built-in page variables, store a reusable Constant, read the clicked element's attributes, pull a query parameter out of the URL, and read a value off a global JavaScript object.
What you'll learn
- Enable and use the built-in page variables (URL, Path, Hostname, Referrer)
- Keep one value in a Constant and reuse it across every tag
- Read the clicked element with an Auto-Event Variable
- Pull UTM and query parameters with a URL variable, and a global with a JavaScript variable
Lessons
- 1→
Built-In Page Variables
Surface Page URL, Path, Hostname and Referrer as built-in variables.
- 2→
Constant Variables
Store a value once (like a Measurement ID) and reuse it across tags.
- 3→
Auto-Event Variables
Read the clicked element's attribute with an Auto-Event Variable.
- 4→
URL & Query Variables
Read UTM and other query parameters with the URL variable.
- 5→
JavaScript Variable
Read a global page variable (window.siteData) with a JavaScript variable.
- 6→
Variables: Recap And Verify
Recap every variable, then check your whole container in one pass.