Install
Works with Drupal: ^10.3 || ^11 || ^12Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
Google Tag 2.1.0 adds Drupal 12 support and fixes a long list of bugs in events, Commerce tracking, the container form and the upgrade from 1.x. Drupal 10.3 is now the minimum supported core version; Drupal 9 and Drupal 10.0 to 10.2 are no longer supported. Sites on those versions stay on 2.0.9.
2.1.0 is the first release from the new 2.x branch, which replaces 2.0.x for development.
Highlights:
- The Google tag and Tag Manager scripts load at the end of the page again, instead of blocking rendering in
<head>as they have since 2.0.6. - Events now reach Tag Manager-only setups, and the
login,sign_upand Webformpurchaseevents are sent after the form redirect instead of being lost. Delayed events no longer get stuck in the Dynamic Page Cache. - Commerce:
purchaseis sent once, when the order is placed, andbegin_checkoutonce per checkout page view. Cart, product and list events no longer fail on unpriced items, products without variations or deleted carts. - Every tag ID is saved, including IDs that share a weight and IDs entered just before clicking Save or Add another.
- Containers can be put in order by dragging them in the container list, and their label can be edited under Advanced settings.
- The Tag Manager
<noscript>iframe can be turned off for each container ID. - New
drush google_tag:createcommand for provisioning scripts (Drush 13.7 or later). - Upgrades from 8.x-1.x now convert disabled containers, the domain condition, and containers whose configuration was imported before the update, and no longer lose advanced settings.
Upgrade notes
- Core requirement:
core_version_requirementis now^10.3 || ^11 || ^12. Composer keeps sites on Drupal 9.5 or 10.0 to 10.2 on 2.0.9. - Development branch: development moves from
2.0.xto2.x. A^2.0requirement already allows 2.1.0. If you follow the development version, change2.0.x-devto2.x-dev. - Run database updates. A new post update registers
weightas the container entity's weight key. - Purchase timing: the Commerce
purchaseevent is now sent when the order is placed, not when it is paid, and only once per order. Orders paid later, for example by bank transfer, are reported at checkout. - Script placement: gtag.js and gtm.js are attached to the page footer again. If you relied on them loading in
<head>(2.0.6 to 2.0.9), check any inline scripts that callgtag()or readdataLayerearly. - gtag.ajax library: it is now attached only together with the Ajax command that needs it. Custom code that used it without that command must attach
google_tag/gtag.ajaxitself. - TagContainerListBuilder now extends
DraggableListBuilder. Subclasses that return plain strings frombuildRow()must return render arrays for every cell exceptlabel. - New containers' weight: a new container is saved with weight 0, so after reordering, check where it lands in the list.
Contributors (28)
japerry, agoradesign, anybody, guiu.rocafort.ferrer, init90, mark_fullmer, alex.bukach, amangupta, ankondrat4, aposudevsky, bkosborne, camslice, codebymikey, cosolom, dagmar, gueguerreiro, jacobsaw, jan kellermann, kgaut, luke.leber, matthiasm11, mortona2k, pameeela, pfrenssen, podarok, sinn, sourav_paul, tbsiqueira
Changelog
Issues: 36 issues resolved.
Changes since 2.0.9 (compare):
Bug
- #3343483 by japerry: Do not push an empty GTM allowlist or blocklist
- #3388487 by japerry: GoogleTagUpgradeManager may fail upgrade for some configurations
- #3406399 by camslice, init90, japerry: purchase event not being sent on successful webform submission
- #3406422 by cosolom, japerry: Sign Up and Login events do not work
- #3410319 by japerry: Commerce begin_checkout event can fire multiple times with ajax panes
- #3420714 by dagmar, guiu.rocafort.ferrer, japerry: Missing options to order containers by weight
- #3420716 by guiu.rocafort.ferrer, japerry: Missing options to edit Label and Machine name for a container
- #3422723 by anybody, japerry: Error: Call to a member function getCurrencyCode() on null (Drupal Commerce WSOD!)
- #3464389 by sourav_paul, japerry: 404 with link to documentation
- #3469014 by bkosborne, japerry: Weight is not preserved when saving multiple tags within the same container
- #3471369 by japerry: google_tag_post_update_move_advanced_settings causes Undefined variable warning
- #3482534 by japerry: Saving multiple google tag Id isn't working
- #3489811 by anybody, japerry: AddToCartEvent WSOD for order items with no price
- #3498247 by sinn, japerry: Only active tag containers are upgraded
- #3499397 by agoradesign, japerry: Delayed events and dynamic page cache do not play well together
- #3512549 by matthiasm11: gtag.js/gtm.js order in D10.4/D11 vs default consent
- #3542554 by ankondrat4, japerry: Warning: Array to string on SearchApiSubscriber
- #3544605 by pfrenssen, japerry: Fatal error in RemoveFromCartEvent
- #3549374 by luke.leber, japerry: Synchronous JS in <head> blocks the critical render path
- #3560472 by tbsiqueira: dl const declaration conflicts with other js files
- #3573774 by amangupta, codebymikey, japerry: the issues reported by phpcs
- #3575350 by japerry: The 'gtag_domain' plugin does not exist
- #3579188 by alex.bukach, japerry: Events do not fire in GTM-only setup
- #3612054 by gueguerreiro, japerry: The 'search' event fires multiple times on SearchApiSubscriber if we are using Views attachments
- #3618810 by kgaut, japerry: gtagEvent Ajax command throws "ReferenceError: gtag is not defined" and breaks the whole Ajax response when gtag.js is blocked
Feature
- #3106318 by jan kellermann, japerry: Make iframe (noscript) optional
- #3356152 by mark_fullmer, japerry: Programmatically create a container with Drush
- #3421335 by mortona2k, japerry: only require gtag.ajax library if it is needed
- #3523282 by japerry: Remove leading and trailing whitespace of tagId for script.src string in js/gtm.js
- #3544798 by aposudevsky, japerry: Environment ID max length should be extended
Task
- #3437889 by agoradesign, japerry: Send the purchase event when an order is placed, not paid
- #3474330 by pameeela: Update logo for compatibility with Project Browser
- #3512028 by init90, japerry: Prevent error on the 'view_item_list' event call
- #3532627 by mark_fullmer, jacobsaw, japerry: [Drupal 12] google_tag_module_implements_alter without a #[LegacyModuleImplementsAlter]
- #3559302 by japerry: Fix or remove Nightwatch tests
- #3598653 by podarok, japerry: Automated Drupal 12 compatibility fixes for google_tag 2.0.x-dev
Misc
- Ignore the Guzzle 8.5 defaultUserAgent() deprecation in core's browser tests