top of page
Writer's picturePanshul Khurana

Integrating Google Analytics and Adobe Analytics with a Drupal website.

Updated: Jul 20, 2022

This blog is in continuation with the Blog "All About Analytics", where we talked about two analytics tool "google analytics" and "adobe analytics". In this blog will be diving more deep into it and we will be learning how to integrate both the analytics tool with the Drupal website and what all configuration options they provide to easily implement analytics with your website.

Implementing Google Analytics to a Drupal website using google_analytics contributed Drupal module.

To implement Google Analytics with drupal website. You can download and install the module here. This module comes up with number of features provided by google analytics for tracking your website. Some of the most vital features are listed below :

  • Provides Single/multi/cross domain tracking , you can specify multiple domains of your website for tracking(including your local environment).

  • You can Selectively track/exclude certain users, roles and pages.

  • Track and Monitor what type of links are tracked (downloads, outgoing and mailto).

  • Track and Monitor what files are downloaded from your pages.

  • Drupal messages tracking.

  • Modal dialog tracking (Colorbox).

  • Access denied (403) and Page not found (404) tracking.

  • Debug mode with analytics_debug.js .

Drupal provides an additional module named “Google Analytics Report” , which can be used to generate and display graphical reports of your site tracking data. The report is visible to the site admin(screenshot attached)


Let us take a closer look at the admin configuration page of the module to understand some of the major components of the settings provided.

After installing the module head towards : admin/config/system/googleanalytics, let’s not forget that to integrate google analytics we must have a registered website on https://analytics.google.com, which will provide us with details that are required to be filled in the config form of google analytics module settings.

The first setting available to admin is :


In the general settings section, it asks for the web property id / tracking id which is unique for your website.

The tracking id for your website is available at https://analytics.google.com/analytics/web/#management/Settings page.


The tracking id is the most important of all the settings available on the config page. It is a Key for linking your website to google Analytics.

Tracking scope : Also in the screenshot of the config page attached above, you can see that there are various settings available under tracking scope label. The 1st one is the Domain .

The settings are available in the form of a radio button, where you can choose how many domains you want to track for your website.

  1. Single domain : This can also be referred to as the default domain of your website. You can choose this if you want to track only one domain of your website.

  2. One domain with Multiple sub-domain : This can be chosen if you have multiple sub-domains of the single domain of your website.

  3. Multiple top level domain : This is useful when your site has multiple top level domains such as www.example.abc.com.

Roles Tracking : The module provides an option to choose users of specific roles that you want to track. You may restrict your tracking to just anonymous and authenticated users and avoid tracking any activity that admin does on the website.


This provides us with the filtered reports, where the tracking data will only include activities done by the specific roles.

Track User ID :


Another most important setting is that the user can track an User ID and maintain that for different sessions across different devices. This helps us in tracking the user activities across different devices.

Track File download Links :


With the above available settings you can choose to track download links , outbound link clicks and mailto link clicks .

In Addition to that , this also allows to match for any regular expressions in the download links. My favourite out of these available options is tracking content in the colorbox model. With just one simple click of checking the check box , you can very easily track if the user/visitor is reading the content in the colorbox popup.

Drupal Message tracking :


Another advantageous feature of this module is that you can very easily track Drupal messages, whether it is a status message, a warning message or an error message.

As you can see in the help text as well. With this feature enabled , you will be able to :

  • Identify usability issues with your website

  • With the option of tracking specific pages , you can limit your message tracking only to those specific pages that you want to track

Adobe Analytics Implementation with Drupal Using siteCatalyst(d7)/adobeanalytics(d8) module

To implement Adobe analytics on your drupal website, you can download and install adobe analytics drupal module from the following links :

  1. For Drupal 7 implementation (SiteCatalyst) : https://www.drupal.org/project/sitecatalyst

  2. For Drupal 8 implementation (AdobeAnalytics) : https://www.drupal.org/project/adobe_analytics

You must have a sitecatalyst account with your site registered and a specific report suite created for your website. As our main focus is to understand the configuration provided by the module , I will limit my blog to just covering the config page. For Integrating a website with sitecatalyst , you can follow up on Adobe SiteCatalyst Integration Document .

Features provided by this module are as follows :

  1. Integrating the JS code with the website by simply just passing the location/path at which your javascript file is located in the “Complete Path to javascript file” field.

  2. Adding custom variables for tracking, whose values are dependent upon the tokens module and the tokens available for the website.

  3. Add custom Javascript code which is embedded in the footer section of html markup of every page and every custom variable that you add. It is added right above the sitecatalyst js code in the html markup.

  4. Track users of specific role (Options depends upon the number of roles defined for a website).

  5. This module provides a hook named as hook_sitecalayst_variables(), which can be used to add variables for tracking from any other module. This hook expects you to return an associative array where the key is the name of the variable and the value is variable's value.

Let us take a closer look at the configuration options provided by this module and in the end then we will be in a position to make clear difference of the functionality provided by both the modules and figure out which best suits for tracking business of a specific enterprise.

Js File Integration :


In the first field “Complete path to siteCatalyst Javascript file”, you are required to enter the URL of the JS tracking code file located on the server.

The JS code can be retrieved and downloaded from the siteCatalyst admin login. Head to Admin menu and in the drop down select “Code manager”. You should be able to see the screen as following, where you can find the tracking code for every implementation :


As you can see the latest upgrade to javascript file is in the first option with the name “Javascript(New)” , Notice that the version of the code here is “1.7.0” .

It is recommended to go for the newest available version but the plugins required are still being migrated to the new JS version named as “AppMeasurement.js” file (Previously s_code.js).

The status of the plugin support for AppMeasurement can be tracked on AppMeasurment Plugin Support.

If you have already implemented s_code.js file and want to upgrade to the latest one, you can head towards the next Blog “Migrating s_code.js to AppMeasurement.js” file with the available plugins.

As you proceed with the migration, you will notice that some of the migrated plugins are not directly accessible and needs to be contacted to Adobe Consultant, who will provide you the plugin code as per your requirement. We will cover that in our next blog.

In case you want to access all the plugins and you have an option of waiting for all the plugins to be migrated to AppMeasurement, you can go with s_code implementation.

In that case click on the “Javascript(Legacy)” link and download the code to modify as per your requirement. A folder named “AppMeasurement_Legacy_JavaScript-H.(version-no).(sub-version-no).” will be downloaded with the following content


Alter the code of s_code.js file as per your tracking needs and host the file on the server from where you can access the file and add it’s path in the drupal configuration provided.

We will cover the code in detail in our next blog and for this blog, we will limit our focus to just the configuration options provided.

The Second most important field in the above configuration screenshot is the “Token Cache Lifetime” :

You get an option to specify the token cache lifetime duration , so that the variable value that you are setting through “Add Custom Variables” configuration and its value as a specific token will have a cache duration set. The token value will be cached for that specific duration only.

User Role Tracking :


Another useful configuration option is the User role tracking , which is pretty much simple to understand that we can select whatever roles we want to track. This is exactly the same configuration provided by “Google Analytics”, The only difference is that of a radio button in GA and select list in Adobe Analytics for adding for selected roles only or add to all except those selected.

Custom variables :


This section is similar to Google Analytics, in terms of adding custom variables for tracking. The siteCatalyst, as mentioned above, provides a hook named hook_sitecatalyst_variables. All the custom variables added here in this form in the form of key value pair, on submitting the form are added to the siteCatalyst JS tracking code, embedded in the HTML markup of the page.

The Difference here relies in the GA provides two areas for adding custom variables in from if “Custom Dimensions” and “Custom Metrics”.

Javascript Custom Code for Tracking :


The Last option provided by the module configuration is the textarea for adding custom JS code for tracking. Using the examples provided , you can simply write one line or two lines of a code for tracking a specific functionality or any custom functionality that you are trying to implement.

What do we know and what have we learnt ?

  • We can clearly see that Google Analytics provides detailed configuration options for setting analytics with a drupal website. Where you can handle almost everything from backend. whereAs siteCatalyst provides limited configuration options from backend. But facilitates in handling all the required operations by altering and adding the JS code for tracking in two ways :

    • Through Custom JS code in Advanced setting of module config page.

    • Altering the s_code/AppMeasurement code provided by Adobe.


  • As soon as you submit the form both modules add a JS tracking code to the HTML markup, if you look at any site that has implemented any of the two modules in the source code page , you will be able to see the code added in the html Mark Up that is responsible for sending tracking details to the reports attached to the website.

  • GoogleAnalytics comes with other products/module that extends Google Analytics tracking functionality in various ways which can be very useful for analyzing and tracking a business which can eventually help you decide in which direction should you take your enterprise or what should be your goals for upcoming time. SiteCatalyst itself provides you with several plugins and modules that you can embed in s_code js file to extend to whatever you want to track.

  • Implementing either of two is pretty much simple but sitecatalyst as mentioned above demands a developer who can modify the s_code file for tracking according to the business requirement. Even though it demands development , the code is not hard to understand and extend. But what can be tedious is making changes in the plugin code(which is a minified javascript code).

All of the points above are my observations regarding the module. There can be another point of view in judging which is best suited for a specific enterprise. There may exist an another tool which is better than both Google Analytics and Sitecatalyst , you can explore them and share your knowledge and observations in the comment section below.

In our next blog we’ll be digging more deep into the code provided in the s_code and how can you migrate this to a newer JS code provided by Adobe named as “AppMeasurement.js”. We'll also discuss how is it better than the previous one.

77 views0 comments

Recent Posts

See All

All About Analytics

Analytics is the practice of methodical exploration of an organization’s data with emphasis on statistical analysis. Some of the most...

Comments


bottom of page