Gtag referenceError: gtag is not define

Dear Suport,

we implemented piwik with google tag manager, but i get now in actual crome and firefox, when checking the console error about ‘‘Uncaught ReferenceError: gtag in not define’’

please see the the screenshot from crome und firefox, please let me know how I can solve this

best wishes
Sally


Hi @sall,

This looks like its not related directly to Piwik PRO Tag Manager itself but rather what is added inside of it.

Gtag not defined errors are usually related to Google Consent Mode implementation (or other Google products). Am I correct to assume you have tried installing the GCM integration?

Hi Anthony,

thanks for your answer, actually this is the tag that gives error

which is created in my piwik container. When I disable the error doesnt appear… what can i do?

thanks

Yep, this is Google Consent Mode. I’d suggest having a look at our article. The content is about GCMv2 but you should also be able to apply this here.
Google consent mode v2 integration | Piwik PRO help center

The 1st step explains how to add the default consent settings. These are not required but it’s highly recommended to add them. In case you don’t want to add the defaults, you can also add this piece of code at the beginning of your tag (or the one from our guide):

window.gtag = window.gtag || function(){dataLayer.push(arguments)}