Lesson 3 of 4
The Four-Question Decision
For any interaction, walk these four questions top to bottom. Stop at the first "yes", that's your method.
1In the dataLayer?→2Can GTM observe it?→3Is it in the DOM?→4Else: listener
The questions
- 1. Is the data already in the dataLayer (or could a dev add it)? → Use a dataLayer variable + Custom Event trigger. Best outcome.
- 2. Can a GTM built-in trigger observe the interaction? (a click, link, form submit, scroll, element visibility) → Use the built-in trigger and click/auto-event variables.
- 3. Is the value sitting in the page's DOM? → Scrape it with a Custom JS / DOM Element variable, as a stopgap, and request a dataLayer push for the long term.
- 4. None of the above? → Write a custom event listener (Custom HTML tag) that catches it and pushes your own event.
Worked example: the demo button
- Does the dev push
demo_request? No. (Q1 no) - Can a built-in Click trigger catch it, scoped by Click Text or a CSS selector? Yes. (Q2 yes → stop)
Method chosen: a Click trigger with a CSS-selector condition. You didn't need to scrape or write a listener, and you didn't wait on a developer.
Key takeaway
Four questions, in order: dataLayer? built-in trigger? DOM? else listener. Stop at the first yes and you've chosen the most reliable available method, every time.