How to integrate Google Analytics with Drupal 8

Parent Feed: 

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 evaluate the effectiveness of your current campaigns and find smart marketing solutions for 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 tracking ID in UA-XXXXXXXX-X format.

tracking ID, 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 specialists who are always ready to help.

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web