Advanced Guide to Implementing Google Ads Conversion Tracking in Drupal Using Google Tag Manager (GTM)
In the digital marketing ecosystem, tracking conversions accurately is paramount for optimizing ad spend and measuring ROI. For marketers and developers working with Drupal, leveraging Google Tag Manager (GTM) to implement Google Ads Conversion Tracking offers flexibility, scalability, and reduced developer reliance.
Why Use GTM with Drupal?
Using GTM with Drupal abstracts away the complexity of direct code modifications. Benefits include:
Prerequisites
Before implementation, ensure the following:
Step 1: Add GTM to Drupal
The simplest way to install GTM in Drupal is via the contributed Google Tag Manager module.
Install the module
composer require drupal/google_tag
drush en google_tag
Or install via the Drupal admin UI if not using Composer.
Configure the module
The GTM script is now automatically injected into all site pages.
Step 2: Set Up Google Ads Conversion Action
Step 3: Create the Conversion Tag in GTM
Step 4: Trigger the Conversion Tag in Drupal
Option A: Track Page Views (e.g., thank you page)
If your Drupal form redirects to a dedicated thank you page after submission (e.g., /thank-you):
In GTM, create a new Page View Trigger for the thank you page.
Link this trigger to your Google Ads conversion tag.
This is the simplest and most reliable method, but it only works if there's a redirect after conversion.
Option B: Track AJAX or On-Page Form Submissions
Drupal forms often use AJAX or stay on the same page. In such cases, use GTM’s custom event tracking capabilities.
Step 1: Push Custom Events to the Data Layer in Drupal
Add a dataLayer.push() JavaScript snippet after successful form submission. For example, in a custom module or theme JS file:
(function ($, Drupal) {
Drupal.behaviors.formSubmissionTracking = {
attach: function (context, settings) {
$('.webform-submission-form', context).once('formTracking').on('submit', function (e) {
$(this).on('ajaxComplete', function () {
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'event': 'drupalFormSubmit',
'formId': $(this).attr('id')
});
});
});
}
};
})(jQuery, Drupal);
Tip: Use once() to prevent multiple bindings if the form is re-rendered via AJAX.
Step 2: Create a Custom Event Trigger in GTM
Step 5: Test Your Implementation
Use the following tools to test the conversion flow:
For form submissions, use console logs to verify dataLayer.push() is firing correctly.
Advanced Tips
1. Dynamic Conversion Values
If your conversion value varies (e.g., based on a donation amount or checkout total):
dataLayer.push({
'event': 'purchaseComplete',
'transactionValue': 49.99
});
In GTM, define a Data Layer Variable named transactionValue, and use it in the conversion tag’s “Value” field.
2. Tag Sequencing
Ensure that the Google Ads Remarketing Tag fires before the conversion tag for better attribution.
In GTM Tag → Advanced Settings > Tag Sequencing, set your remarketing tag to fire first.
3. Cross-Domain Tracking
If your conversion completes on a different domain (e.g., PayPal, external app), enable cross-domain tracking via GA4 and link your Ads account to GA.
Conclusion
Implementing Google Ads conversion tracking in Drupal via Google Tag Manager enables robust, scalable, and low-friction measurement. Whether your site uses basic pageview-based confirmations or AJAX-enhanced forms, GTM allows for flexible solutions that minimize direct code editing and improve maintainability. Coupled with rigorous testing and version-controlled deployment, this approach empowers both marketers and developers to iterate faster and measure smarter.
I’m passionate about empowering organizations with data-driven decision-making while respecting user privacy.
Here’s how you can connect with me or view my work:
Upwork Profile: Upwork
Freelancer Profile: Freelancer
My Blog on GTM & Website Analytics: Google Tag Manager Solution
If you or someone in your network is looking for an experienced professional in this space, I’d love to connect and chat further!