Comprehensive Google Tag Manager guide covering container setup, tags, triggers, variables, data layer, debugging, custom templates, and API automation...
Expertise for Google Tag Manager (GTM) covering container setup, tag configuration, triggers, variables, data layer implementation, debugging, custom templates, and API automation. See the reference files below for detailed guidance on each topic.
Invoke when setting up or configuring GTM containers, tags, triggers, or variables; implementing the data layer; debugging with Preview mode or Tag Assistant; building custom templates; automating via the REST API; or optimising container performance and consent management.
Example: Google Tag (GA4)
Tag Type: Google Tag
Tag ID: G-XXXXXXXXXX
Trigger: All Pages
See tags.md for comprehensive tag documentation.
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'event': 'custom_event',
'category': 'engagement',
'action': 'button_click',
'label': 'CTA Button'
});
See datalayer.md for data layer patterns.
Tags are snippets of code that execute on your site (e.g., GA4, Google Ads, Facebook Pixel).
Triggers define when tags fire (e.g., page views, clicks, form submissions).
Variables capture dynamic values for use in tags and triggers (e.g., page URL, click text, data layer values).
User Action --> Trigger Fires --> Tag Executes --> Data Sent
^ |
| v
+--- Variables provide values -------+
form_submit) with form ID/name as parameterES5 Required: Custom JavaScript Variables and Custom HTML Tags must use ES5 syntax (var, function(), string concatenation). Custom Templates support some ES6. See best-practices.md for details and workarounds.
RE2 Regex: GTM uses RE2 regex - no lookahead, lookbehind, or backreferences. See best-practices.md for supported patterns.
Page View, Click (All Elements / Just Links), Form Submission, Custom Event, History Change (SPAs), Timer, Scroll Depth
// Page view
dataLayer.push({ 'event': 'page_view' });
// User login
dataLayer.push({ 'event': 'login', 'method': 'Google' });
// Purchase
dataLayer.push({
'event': 'purchase',
'ecommerce': {
'transaction_id': 'T12345',
'value': 99.99,
'currency': 'AUD',
'items': [...]
}
});
| Topic | Reference File |
|---|---|
| Container setup | setup.md |
| Tag configuration | tags.md |
| Trigger configuration | triggers.md |
| Variable configuration | variables.md |
| Data layer | datalayer.md |
| Debugging | debugging.md |
| Best practices, naming, performance, security | best-practices.md |
| Custom templates | custom-templates.md |
| API automation | api.md |