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?
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communityI 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()