Highlight that GTM is present
Checks for the gtm.js script or a dataLayer array and shows a green badge when the page uses Tag Manager.
Code to copy
try {
var hasScript = !!document.querySelector('script[src*="googletagmanager.com/gtm.js"]');
var hasDL = Array.isArray(window.dataLayer);
if (hasScript || hasDL) {
var b = document.createElement('div');
b.textContent = 'GTM detected' + (hasScript ? ' (gtm.js)' : ' (dataLayer)');
b.style.cssText = 'position:fixed;top:8px;right:8px;z-index:2147483647;'
+ 'background:#34A853;color:#fff;font:700 12px sans-serif;'
+ 'padding:4px 10px;border-radius:6px;pointer-events:none;';
document.body.appendChild(b);
} else {
console.log('No Google Tag Manager detected on this page.');
}
} catch (e) {
console.warn('GTM detection failed:', e);
}
How to use this example
- Copy the code with the button above.
- Install JustZix (2 minutes) and open the extension on the target page.
- Add a new rule matching that page.
- Paste the code into the rule's JavaScript panel and save — it runs on every page visit.
Rate this example
No ratings yet — be the first.