Google Tag Manager on Acquia (Drupal Cloud) | OpsBlu Docs

Google Tag Manager on Acquia (Drupal Cloud)

How to install and configure Google Tag Manager on Acquia (Drupal Cloud). Covers installation method, container setup, verification, and Acquia (Drupal...

For general GTM concepts, see Google Tag Manager Overview

Overview

Acquia is a managed Drupal hosting platform. GTM setup is identical to standard Drupal — use the Google Tag module.

Prerequisites

Installation

Where to Add GTM Code

Install the Google Tag module: composer require drupal/google_tag && drush en google_tag -y. Then configure at Configuration → System → Google Tag Manager (/admin/config/system/google_tag)

Plugin / Extension

Google Tag module (drupal/google_tag) — the standard Drupal GTM module works on Acquia without modification.

GTM Head Snippet

Add this in the <head> section:

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->

GTM Body Snippet

Add this immediately after the opening <body> tag:

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

Replace GTM-XXXXXXX with your actual Container ID in both snippets.

Acquia (Drupal Cloud)-Specific Considerations

Acquia Cloud uses Varnish caching and a CDN. After enabling the Google Tag module, clear Varnish cache from the Acquia Cloud UI or via drush cr. The module's BigPipe compatibility setting should be enabled for Acquia's infrastructure.

Template System

Acquia (Drupal Cloud) uses Twig templates (standard Drupal theming). When editing templates directly, note that the GTM JavaScript snippet (inside <script> tags) will not conflict with the template engine's syntax.

Verification

After installation, verify GTM is working:

  1. GTM Preview Mode — In GTM, click Preview, enter your site URL, and verify the container loads.
  2. Browser Console — Open DevTools (F12) and run console.log(window.google_tag_manager). You should see an object (not undefined).
  3. Network TabFilter for googletagmanager.com and verify gtm.js loads with a 200 response.
  4. Data Layer Check — Run console.log(window.dataLayer) to verify the data layer array exists.

Next Steps