<p>This code will let you disable the inclusion of the tag:</p>

<pre><code>{% do seomatic.script.get('googleTagManager').include(false) %}
</code></pre>

<p>For more, check out the <a href="https://github.com/nystudio107/craft-seomatic#twig-templating" rel="nofollow noreferrer">SEOmatic Twig Templating documentation</a></p>

<p>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):</p>

<pre><code>{% do seomatic.script.container().clearCache(true) %}
</code></pre>

<p>Also check out the <a href="https://nystudio107.com/blog/tips-for-using-seomatic-effectively" rel="nofollow noreferrer">Advanced SEOmatic Tips</a> article for some deeper reading.</p>

CC BY-SA 4.0
2019-04-05T14:49:00.950Z
Using clearCache gave me this error: `Calling unknown method: nystudio107\seomatic\services\Script::clearCache()`
Piotr Pogorzelski
CC BY-SA 4.0
2019-04-05T19:58:47.120Z
My bad, I left out the `.container()` -- I edited the answer
andrew.welch
CC BY-SA 4.0
2019-04-05T13:37:54.653Z
2019-04-06T14:09:26.197Z
2019-04-06T14:09:26.197Z
andrew.welch
<p>I am using Seomatic and i want to conditionally render google tag manager trancking code - or not. </p>

<p>How do I disable it using some Twig template code?</p>

<plugin-seomatic>
Seomatic - disable tag manager from inside template
# Seomatic - disable tag manager from inside template

(Asked by: username_0 on 2019-04-05)

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?

**Tags:** plugin-seomatic


---

## 1 answers

### Answer by username_1 on 2019-04-05. Score: 1

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.

> **Comments:**
> **username_0**: Using clearCache gave me this error: `Calling unknown method: nystudio107\seomatic\services\Script::clearCache()`  
> **username_1**: My bad, I left out the `.container()` -- I edited the answer  

---

