How to work with the Google Analytics module in Drupal

How to work with the Google Analytics module in Drupal

Getting detailed insights into your website traffic and customer behavior is priceless. However, this can be available to anyone for free with Google Analytics. All you need is to install the tool and dive into its valuable statistics.

Today, we will show how the Drupal Google Analytics module can help you easily configure GA on your Drupal website. Let our journey into Google Analytics for Drupal begin!

Get familiar with Google Analytics

Google Analytics is definitely the favorite service of most SEO specialists and marketing managers. It is also highly appreciated by business owners, developers, website administrators and everyone who knows the value of good web analytics.

Google process image

Google Analytics allows you to gain a deeper understanding of your customers so you can evaluate and optimize your marketing campaigns, content strategy, products or services, etc. To analyze the behavior of your users, Google leverages machine learning capabilities.

With GA, you can discover, in every detail, where your users come from, what is their journey through your website, what pages they love and hate, what keywords they use to find you, what is the “ profile ” of your typical customer and much more.

In addition to getting the data, you can share it in a convenient way through detailed GA reports. Google Analytics also integrates with other Google solutions like Google Ads , AdSense , Search Console , etc.

The Google Analytics service is free in its basic version. There is also a paid version called Google Analytics 360 which is recommended for large companies. It has additional integrations (Ad Manager, Display & Video 360, Search Ads 360, Campaign Manager 360, Google BigQuery, Salesforce Marketing Cloud, etc.), as well as more advanced analytics opportunities.

GA + Drupal: Google Analytics module for Drupal

The Google Analytics module currently ranks 14th out of over 46,000 contributed modules on drupal.org. This is not a surprise since the module easily integrates Google Analytics statistics with your Drupal website.

All you need to do is sign up for Google Analytics and get the ID, and the Drupal module will do the rest of the integration work. It frees you from the need to paste the Google Analytics ID into the HTML code of all your pages, as it provides a handy box in the user interface to do so. You will only paste the ID once using the Drupal admin panel.

This makes the Drupal Google Analytics module a very easy-to-use solution for non-technical users, as is often the case for SEO and marketing specialists. With the ID added, you will immediately find the GA settings available in the administration panel of your Drupal website.

The Google Analytics module has versions to be installed on Drupal 7, Drupal 8 and Drupal 9 websites. Let's see it in action now.

Guide to using the Google Analytics module for Drupal

  1. Getting the Google Analytics ID

First of all, you will need the tracking ID that will set the GA wheels in motion. Go to the Google Analytics website (you will need to sign in with your Google account or create one first). Open the “Administrator” tab and click on “Create Property”. The property will be your Drupal website. Fill in only a few required details about it and check the boxes to agree to Google's terms of service.

User form image

Once you have completed your registration, go to the Property Settings page and copy your Property ID.

Registration image

In case you already have your website registered with GA, you can skip the steps described above. Simply go to the “Administrator” tab in GA, find your property and click on Property Settings to copy the ID. Save the ID and let's move on to the Drupal part.

Image property configuration

2. Drupal module installation and basic configuration

Next, you will need to download the Google Analytics module and enable it on your Drupal website. We are using the Google Analytics module from Drupal 8 (version 8.x-3.1) in our example, so we will demonstrate how to add Google Analytics to Drupal 8.

Drupal basic configuration image

After enabling the module, you will need to click “Configure” right away to open the module configuration. Another way is to go to Settings> System and select Google Analytics.

In “General Settings”, paste the Property ID you just copied from GA into the “Web Property ID” box. Follow the ID entry format specified by your Drupal admin panel. This means you may need to enter the ID after the prefix and also put a hyphen between the digits. Save the configuration.

Google analytics configuration image

 3. Using the module's key configuration

In addition to submitting the property ID, there are many interesting things to configure on the Google Analytics settings page. You can skip this because the defaults are reasonable for most websites. However, knowing the settings is important. Let's start with the list of “Tracking Scope” settings.

Single or multiple domains
You can use Google Analytics if you have a single domain (e.g. website.com), multiple subdomains within a domain (e.g. website.com, store.com, etc.) or even multiple top-level domains ( e.g. website.com, website.org, etc.). The default setting is for a single domain, so be sure to change it if you are using a different configuration.

Module key configuration image

Page tracking 

You can decide which pages should or should not include GA tracking codes. Use one of two modes: list the pages you want to exclude from tracking or those you want to include.

Page tracking image

Role tracking

The next setting deals with the roles of the users you may want to track. For example, the actions performed by website administrators on your website may not be important to get a complete picture of your users' behavior, so you can exclude them from tracking. Similar to the settings above, you can use opt-out or opt-in mode.

Image role tracking

User tracking

You can allow your users to decide whether they want to be tracked by GA or not. The most attractive option is the second one, which tracks users by default, but allows them to opt-out in case they have the “Opt-in or out of tracking” permission. Alternatively, you can select the 3d option which works the other way around. Finally, there is an option to track the user's Drupal ID on all devices, but you should be careful with that for the sake of privacy and GDPR compliance.

User tracking image

Link and download tracking

GA will allow you to track the number of clicks on your website links and downloadable files. You can select link types and file extensions for tracking. The default configuration has tracking enabled for inbound links, outbound links and links to files of many extensions.

Image link tracking and downloads

Message tracking

By tracking the status, warnings and error messages your users receive, you can analyze the usability of your website. Since each message is a separate occurrence, you can also track conversions, for example, by tracking messages about successfully sent subscriptions or placed orders.

Image message tracking

Search and ad tracking

The following configuration allows you to enable the tracking of your internal search keywords, integrate with AdSense ads, and track more advanced display advertising features, such as remarketing, demographics, and interests reports. However, tracking advertising features needs a careful approach because it can run into conflict with GDPR legislation.

Image search and ad tracking

IP address anonymization

It is recommended to enable the following option for privacy reasons, although it may slightly influence the accuracy of the geo-data you receive. Google may remove the last part of a user's IP address before storing it.

Image about IP anonymization

Custom dimensions and metrics

The next level of complexity is to set your custom dimensions and metrics in addition to those tracked by default. This allows you to track specific scenarios in the workings of your website. For example, you will be able to track the performance of promoted content, the difference between logged in and logged out users, the popularity of content from specific authors, etc. You can specify dimension names and metrics on the configuration page of your Drupal module, but you should have already configured them in your GA interface. The use of tokens is allowed.

Advanced settings

Finally, there are some advanced settings for particularly tech-savvy admins. They include a local cache tracking code file, adding custom JavaScript code snippets, enabling GA debugging, and more.

Image advanced settings

Once you've completed your setup, don't forget to click "Save" at the bottom of the page. It may take up to 24 hours for Google to activate your tracking. After that, you can dive into the exciting statistics in your Google Analytics interface.

When talking about tracking GA results, we should mention another interesting module: Drupal  Google Analytics Reports  . It presents your tracking data in the form of graphical reports. With this Drupal module, you will be able to create a Google Analytics dashboard with the key metrics within your Drupal site.

Imagen panel Google analytics

Ask Google to share its valuable insights with you.

The famous search giant is kind enough to equip your website with all the tools that will help you succeed on the World Wide Web. Simply use what Google offers and combine it with Drupal solutions for your website. Whenever you need help setting up Google Analytics for Drupal, feel free to contact our development team.

 

Taken and translated from: https://gole.ms/blog/how-work-google-analytics-module-drupal