How to integrate Google Analytics with Drupal 8

How to integrate Google Analytics with Drupal 8

Probably the first place among web analytics services belongs to Google Analytics, which is the most widely used analytics site on the Internet now. You can apply Google Analytics in content marketing, in social media marketing, in e-mail marketing and almost anywhere. This feature-rich tool allows you to evaluate the effectiveness of your current campaigns and find smart marketing solutions for the future. Two additional versions of it have also been created: Google Analytics for mobile apps and Google Analytics 360 Suite. Also, the Drupal community have developed a module to help Drupal site owners implement this service more easily.

How can Google Analytics module save your time & efforts?

In order to obtain all of Universal Analytics’ benefits and track every page that your web resource contains, Google suggest you use a tracking code. You have to copy and paste this JavaScript snippet into every page’s code. This is not hard if your site is not very big, but if you have a web portal with numerous pages, it can be a tremendously monotonous and tedious activity. So make life easier with the Google Analytics module. Just paste a tracking ID in its configuration page and that’s enough. Sounds great, isn’t it? Let’s go step by step.

How to enable Google Analytics module in Drupal 8?

First, go to this link to create a GA account. After filling in all the fields that you see, press a blue button called “Get Tracking ID” at the end of this page.

create Google Analytics account

After accepting all the terms of service agreement, you get a measurement ID in G-XXXXXXXXXX format.

tracking code in Google Analytics

Leave the tab with GA account open. Now login to your Drupal site using the admin credentials. Download and install the Google Analytics module as you normally install Drupal modules on your website and then enable it. There are two versions now available: 7th and 8th. But we recommend you build your site with Drupal 8 and install the Drupal 8 version of the GA module.

After installing, go back to the tab with the Google Analytics account and copy the Tracking ID from there. Paste it in the field titled “Web Property ID” on your website: Configuration→Google Analytics→General Settings→Web Property ID. Click “Save Configuration” and that’s it. Your Google Analytics is now set up.

Now you can track data, monitor statistics, and see ways to optimize your website — and therefore business. If you have any questions regarding this, please contact our Drupal development specialists, who are always ready to help.

2 votes, Rating: 5

Read also


Our tradition of presenting you short overviews of several modules of the month continues with today’s article. Previously we offered you some great contributed Drupal 8 modules in June 2016 a...


The SEO Checklist module tells you what modules to install and what actions to perform so you can use the best SEO practices with Drupal. It does it in a user-friendly and popular way that most...


If you are a businessperson or your company’s web resource owner, what benefits will Drupal 8 give you? What will it help you gain? What marketing qualities does it add? We’ll answer these...


Drupal 8 is so irresistible in its innovations that it just makes you wanna… pack your things and migrate! ;) To “pack” your website’s content and configuration carefully and move them to Drupal 8...


It’s a joy to see how Drupal 8 fulfills its promise of becoming more convenient in every way! We’ve discussed how it respects web accessibility standards, facilitates product management with the...

Subscribe to our blog updates