For Drupal 9 (and also Drupal 8) thereThere is a new module (COOKiESfor Drupal 8 and 9: https://www.drupal.org/project/cookiesCOOKiES) that. It supports the modules "Google Analytics"Google Analytics and "GoogleGoogle Tag Manager"Manager (and more). May be that’s itMaybe that's what you are looking for.
COOKiES
User consent management module for Drupal 8 and 9.
The module enables existing third-party-integration modules continued to be used in compliance with the GDPR (of course without manipulating their code). It solves the basic problem that when using third-party-integration modules, the user must agree to the use of cookies (according to GDPR) before they are installed.
IMPORTANT: No liability is assumed regarding compliance with the GDPR.
The COOKiES module provides (with the Library Cookies JSR) a fully configurable user interface for user decisions. It also supports out-of-the-box some key third-party integration modules (especially those included in the Thunder distribution):
- Google Analytics module
- Google Tag Manager
- Video embed, core:media module
- Twitter media module
- Instagram media module