How To Test Google Tag Manager on a Drupal Development Environment

I recently had to set up a Google Tag Manger container on a development environment to evaluate how refactoring JavaScript used for third party advertisements would improve performance. To grasp the full scale of the improvement, some tags, triggers, and variables from Google Tag Manager would not be required and in fact were conflicting with the refactoring task.

Therefore to test accurately it was important to test the development environment with certain tags, triggers, and variables removed from a published Google Tag Manager version.

Disclaimer: This may not always be required. It’s probably appropriate to save changes to the ‘live version’ and test or verify using the shared preview link. That’s your call. 

In this situation, given that development environment was going to require third party performance audits AND the live version COULD NOT be changed yet… I was introduced to Google Tag Manager environments and.. how easy it is to use them with Drupal google tag module.

Click the link above to learn more about Google Tag Manager environments link above how to set up a new environment.

What I’m showing here is how to configure your Drupal environment (Development, Multidev, local) to use that alternate environment.

Step 1: Navigate to the Google Tag Manager configuration in Drupal. This is probably accessible at the path “/admin/config/system/google_tag”

Step 2: Click Advanced and check Include an environment and grab the Environment ID and the Environment token from the Google Tag Manager environment snippet that is provided upon set up.

It makes the process of testing out Tag Manager on a development or staging environment fast and simple.

Drupal Google Analytics Advanced Configuration