On-page badge of GTM container IDs
Finds every GTM-XXXX container identifier on the page and shows them in a small badge in the screen corner.
Code to copy
try {
var ids = {};
document.querySelectorAll('script[src]').forEach(function (s) {
var m = s.src.match(/[?&]id=(GTM-[A-Z0-9]{4,8})/);
if (m) { ids[m[1]] = true; }
});
var html = document.documentElement.innerHTML.match(/GTM-[A-Z0-9]{4,8}/g) || [];
html.forEach(function (id) { ids[id] = true; });
var list = Object.keys(ids);
var b = document.createElement('div');
b.textContent = list.length ? 'GTM: ' + list.join(', ') : 'GTM: none found';
b.style.cssText = 'position:fixed;bottom:8px;right:8px;z-index:2147483647;'
+ 'background:#202124;color:#F9AB00;font:700 12px monospace;'
+ 'padding:4px 10px;border-radius:6px;pointer-events:none;';
document.body.appendChild(b);
} catch (e) {
console.warn('GTM badge 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.