Add GA4 snippet support in cookies_ga

Created on 2 June 2023, over 1 year ago
Updated 27 September 2023, about 1 year ago

Firstly, Thanks for making this module available, which saves us a huge time while implementing GDPR.

Problem/Motivation

The current cookies_ga is not working with google_analytics module anymore, causing the implementation not GDPR compliant.

The GA4 snippet given in Google Analytics tool or generated by google_analytics module contains this script tag:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXX"></script>

Important: Universal Analytics will be discontinued by 1st July and all users must migrate to Google Analytics 4 (GA4) immediately.

Steps to reproduce

As is:

- Enable and configure the modules cookies, cookies_ga and google_analytics.
- Using an incognito window without any cookies set, be sure that the cookie banner will appear.
- Without giving consent, inspect the HTML and note that the GA4 script will be incorrectly enabled.

As should:

- Without giving consent, the GA4 script must be disabled and only placed after user consent.

Proposed Solution

Recognize the script source format (https://www.googletagmanager.com/gtag/js?id=) as a GA tag and apply the usual consent logic.

Feature request
Status

Fixed

Version

1.2

Component

Submodule: cookies_ga

Created by

🇧🇷Brazil nataliaalves

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024