Drupal 7 - Issues outputting the inline tag and triggering page View events when JS aggregation is turned ON

Created on 25 May 2023, over 1 year ago
Updated 1 June 2023, over 1 year ago

Problem/Motivation

The script tag is not in the head of the html document when JS aggregation is turned ON. The Iframe with the Google tag is rendered properly, but the enabling tag cannot be soon in source, tag manager fails to discover the tag, Page View events are not triggered.

<script src="https://www.googletagmanager.com/gtm.js?id=GTM-1234565" async=""></script>

Steps to reproduce

  • Go to /admin/config/development/performance
  • Check the Aggregate JavaScript files setting (preprocess_js)
  • Enable the Google Tag Module, with default settings
  • Create a new container with your GTM code, with default settings
  • Reload a front end page of the site and look for the tag number in the page's source code
  • the Iframe is there, and script tag nowhere to be seen
  • No analytics event is triggered by the aggregated js code

The module works great without JS aggregation. Possibly I am not clear on proper configuration, I have tried with and without the file snippet, tweaked the various top-level and container options, to no avail.

I am using the Google Tag Manager preview toolkit, as well as the Google Analytics 4 Real-time preview and debug views in various staging environments and in production.

I am using 7.x-2.1 on Drupal 7.97.

Related issue : https://www.drupal.org/project/google_tag/issues/2900706

Thank you for any advice.

💬 Support request
Status

Active

Version

2.0

Component

Code

Created by

🇨🇦Canada tondeuse

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

Comments & Activities

Production build 0.71.5 2024