Which version should I use?
- 2.x (2.1.0 and later) is the current branch. It supports Drupal 10.3, 11 and 12, and both Google tag (gtag.js) and Google Tag Manager. Use it for Google Analytics 4, Google Ads and Tag Manager.
- 8.x-1.x supports Drupal 8.8 to 10 and Google Tag Manager only. New features are added to 2.x only.
- 7.x branches are for Drupal 7, which reached end of life in January 2025.
Google Tag adds Google Tag Manager and the Google tag (gtag.js) to your site, so you can run Google Analytics, Google Ads and other measurement tags. You choose which pages, roles and responses the tags load on, and the module can send common events, such as logins, searches and Commerce purchases, without any custom JavaScript.
Features
- Google tag and Tag Manager IDs in one place. Add any mix of Google tag IDs (
G-,AW-,DC-,GT-) and Tag Manager container IDs (GTM-), and order them by weight. - Insertion conditions. Load tags only on certain paths, for certain user roles, or for certain response status codes. Any condition plugin on your site can be used, including ones from other modules, and a language condition appears on multilingual sites.
- Multiple tag containers. Most sites need one. If different tag IDs need different conditions or events, turn on multiple containers in the module settings. The container list is drag-and-drop: the first enabled container whose conditions match is used.
- Events. Send GA4 recommended events automatically (see below). Each event can be turned off per container.
- Custom dimensions and metrics. Add custom parameters to the Google tag configuration, with token support.
- Consent Mode. "Enforce Privacy Consent Policy" sets Google's default consent state to denied, so a consent management tool can grant it once the visitor agrees.
- Tag Manager options per container ID. Data layer name, allowed and blocked tag classes, environment ID and token, and whether to add the
<noscript>fallback iframe. - Content Security Policy. Works with the CSP module, which adds Google's domains to your policy.
- Drush.
drush google_tag:create --id=GTM-XXXXXXXcreates a container and makes it the default, for provisioning scripts. It needs Drush 13.7 or later.
Events
Events are sent with gtag.js, which also adds them to the data layer for Tag Manager. Events that depend on another module appear only when that module is installed.
- Core:
login,sign_upandsearch(core Search and Search API views). - Commerce:
view_item,view_item_list,add_to_cart,remove_from_cart,begin_checkout,add_shipping_info,add_payment_info,purchaseandrefund, plusadd_to_wishlistwith Commerce Wishlist. - Webform: a webform handler that sends a
purchaseevent when a submission is saved. - Your own code: the
google_tag.event_collectorservice can sendgenerate_leador any custom event. UseaddDelayedEvent()for events that happen before a redirect, so they are sent on the next page.
Getting started
- Install the module with
composer require drupal/google_tagand enable it. - Go to Configuration » Web services » Google Tag (
/admin/config/services/google-tag). - Enter your Google tag ID or Tag Manager container ID. Add more IDs if you need them.
- Review the events, conditions and advanced settings, then save.
Upgrading
- From 8.x-1.x: update the code to 2.x and run database updates (
drush updatedb). Existing containers and their settings are converted. Run the database updates before importing configuration, so the old settings are not removed before they are converted. - From the Google Analytics module: when Google Tag is installed, it imports the Google Analytics module's settings into a new container and stops that module from adding its own script, so tags are not sent twice. You can uninstall Google Analytics afterwards.
Placement and Google Search Console
The Google tag and Tag Manager scripts load asynchronously at the end of the page, and the Tag Manager <noscript> iframe is added at the top of the body using standard Drupal hooks. Search Console's Tag Manager verification may report that the snippet is not "immediately after the opening body tag". This does not affect tracking. If you need it there for verification, move it in your theme's html.html.twig, or verify the site another way.
Support
Report bugs and feature requests in the issue queue. Please include the module and Drupal versions, and which tag IDs and events you use.
Project information
- Project categories: Integrations
138,247 sites report using this module
- Created by solotandem on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 2.x-dev updated 17 Nov 2026 at 05:36 UTC
PHP 8.4 deprecation fix
Development version: 2.0.x-dev updated 17 Nov 2026 at 05:06 UTC
Development version: 8.x-1.x-dev updated 28 Jan 2025 at 19:47 UTC




