google-analyticsfirebase-analyticsgoogle-analytics-firebasegoogle-analytics-4

Consent Mode in Firebase Analytics for web apps


Is it possible to set Consent Mode for Firebase Analytics (GA4) JS SDK (web app)? The documentation seems to be only for mobile apps. If not, is there any other way to turn off their cookies for GDPR compliance?


Solution

  • There is a setConsent method documented here.

    setConsent()

    Sets the applicable end user consent state for this web app across all gtag references once Firebase Analytics is initialized.

    Use the ConsentSettings to specify individual consent type values. By default consent types are set to "granted".

    export declare function setConsent(consentSettings: ConsentSettings): void;