google tagmanager errors

hi, on this website: joiny.nl I have installed google tagmanager script in header and body. I get errors:
GTM is present in the code, but not executed

Although the Google Tag Manager container (GTM-PK4D64WT) is technically included on the site, it is not being executed correctly. The main causes are:

Invalid HTML structure
Gridbox scripts rewriting the DOM
Tag Assistant preview cookies not being set
Testing on a non-production (preview) URL

1. HTML errors are breaking GTM and the preview mode

When inspecting the page, the HTML structure turns out to be invalid. Because of this, the browser cannot properly build the DOM, which prevents:

GTM from running correctly

The Tag Assistant preview window (iframe) from loading

Key issues:

Elements that belong in the

appear inside the , for example:






This breaks the HTML parser.

Multiple duplicated or hidden Gridbox elements (

,

,
) exist with extreme negative offsets.

Gridbox rewrites parts of the DOM while the page loads, which becomes problematic when the HTML is already invalid.

Conclusion: As long as the HTML is not valid, GTM and its preview mode will remain unreliable.

2. Gridbox / Joomshopping scripts interfere with GTM Preview

Gridbox behaves as a dynamic page builder and modifies the page structure:

Sections of the and are rewritten dynamically

Content is sometimes loaded through AJAX

Scripts are combined, moved, or deferred

Joomla injects additional inline scripts and JSON

The GTM preview attempts to inject an iframe into the DOM.
If the DOM is still being rewritten at that moment, the injection fails.

3. GTM loads, but the Tag Assistant preview cookie is not being set

Normally, Tag Assistant places cookies like _TAG_ASSISTANT on the domain.
This is not happening consistently on this site, which causes the preview to fail.

Possible reasons:

A privacy layer or Joomla plugin blocks cookies

Optimization tools (Cloudflare RocketLoader, JS minifiers, script combiners) interfere with third-party scripts

The site is viewed through a Plesk Site Preview URL, for example:
/plesk-site-preview/sleepy-khayyam...

⚠️ GTM Preview never works on Plesk preview URLs.
It only works on the actual domain.

4. Quick diagnostic checks in Chrome DevTools
1. Type in Console:
dataLayer


If this gives an error → GTM is not correctly loaded (usually due to parse errors or JS issues).

2. Check page load state:
document.readyState


If it stays at "loading" → the DOM was never fully built → strong sign of invalid HTML or broken scripts.

Solutions (in priority order)
Solution 1 — Clean up the HTML (highest priority)

Remove duplicate




Remove any
or similar tags that mistakenly appear inside the .

Check all Gridbox blocks for:

Hidden or duplicate
/
/ tags

Elements with extreme negative positioning

Validate the HTML via an online validator and fix the critical errors first.

GTM Preview cannot work reliably if the HTML is not valid.

Solution 2 — Temporarily disable all optimizations

To test GTM preview cleanly:

Turn off all JS/CSS optimization:

JSpeed

Gridbox compressor

Lazy loading

JS minifiers

Disable Cloudflare features such as RocketLoader

Restart preview via:
https://tagassistant.google.com

If the preview works now → the issue is caused by an optimization tool.

Solution 3 — Remove old service workers

Open Chrome DevTools → Application → Service Workers

Click Unregister

Reload the site

Old service workers may cache outdated scripts and block GTM Preview.

Solution 4 — Always test on the real domain

The container GTM-PK4D64WT must be tested on:

https://joiny.nl

Not on:

Plesk preview URLs

Staging domains

Temporary URLs

Use debug mode:

https://joiny.nl/?gtm_debug=x

Short action plan for your developer

Fix invalid HTML

Remove misplaced and
tags from the .

Clean up Gridbox-generated duplicate or hidden elements.

Insert GTM cleanly

Add GTM script in and the noscript iframe immediately after .

Avoid injecting GTM through Gridbox modules.

Disable all optimizations temporarily

Minifiers, lazy loading, script combining, Cloudflare RocketLoader.

Clear caches & service workers

Test only on the real domain using Tag Assistant

Replies are visible only to logged in members with an active subscription.