I am using Seomatic and i want to conditionally render google tag manager trancking code - or not.
How do I disable it using some Twig template code?
This code will let you disable the inclusion of the tag:
{% do seomatic.script.get('googleTagManager').include(false) %}
For more, check out the SEOmatic Twig Templating documentation
If you're changing the inclusion of the tag or not based on some other variable such that the tag may be included or not for the exact same URI, you'll want to bust the cache, too (which is URI-based):
{% do seomatic.script.container().clearCache(true) %}
Also check out the Advanced SEOmatic Tips article for some deeper reading.
Calling unknown method: nystudio107\seomatic\services\Script::clearCache()
Commented
Apr 5, 2019 at 14:49
.container()
-- I edited the answer
Commented
Apr 5, 2019 at 19:58