Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Google Analytics Cookieless

Security covered Obsolete 4 sites

This module allows for Google Analytics tracking without using cookies, by generating a unique user ID based on browser fingerprinting. It also supports IP anonymization, selective page tracking, and excluding logged-in users.

As Google Analytics 4 uses first-party cookies instead of third-party cookies to comply with laws like GDPR: this module is now deprecated

You should migrate to Google Analytics module before the legacy GA service shuts down July 1st 2023

You want to add Google Analytics tracking to your website but do no want to use the GA cookie which comes along ? You have a simple site and you don't want to display the annoying cookie banner just for Analytics tracking ?

This module allows you to collect statistics about your visitors via Google Analytics without having to set the GA cookie on your website.

Features

  • Google Analytics tracking without GA cookie
  • Single domain tracking
  • Anonymize visitors IP address (by default)
  • Selectively track/exclude certain pages
  • Track / Do not track logged in users

How it works

When calling the Google Analytics code snippet, this module deactivates the cookie storage and generate a user ID by using a browser Fingerprint with the Fingerprintjs2 library :

Fingerprint2.get(function (components) {
    var values = components.map(function (component) {
        return component.value;
    });
    var murmur = Fingerprint2.x64hash128(values.join(''), 31);
    ga('create', drupalSettings.google_analytics_cookieless.ga_account, {
        'storage': 'none',
        'clientId': murmur
    });
    ga('set', 'anonymizeIp', drupalSettings.google_analytics_cookieless.ga_anonymise_ip);
    ga('send', 'pageview');
})

Installation

The installation of this module requires the eternal library FingerPrintJS.

First enable the Drupal module like any other modules.

1. Copy/upload the google_analytics_cookieless module to the modules directory of your Drupal
installation.

2. Enable the 'Google Analytics Cookieless' module in 'Extend'.
(/admin/modules)

3. You can use composer to download and install the FingerprintJS library.

a. For this you have to add to your composer.json file the following repository:

  "repositories": [
    {
      "type": "composer",
      "url": "https://packages.drupal.org/8"
    },
    {
          "type": "package",
          "package": {
            "name": "valve/fingerprintjs2",
            "version": "2.1.0",
            "type": "drupal-library",
            "extra": {
              "installer-name": "fingerprintjs"
            },
            "source": {
              "url": "https://github.com/Valve/fingerprintjs2",
              "type": "git",
              "reference": "2.1.0"
            }
          }
    }

b. Then add the library as a required composer package :

composer require --prefer-dist valve/fingerprintjs2

Otherwise (not recommended) you could download the library from https://github.com/Valve/fingerprintjs2
and place the following file fingerprint2.js under the libraries/fingerprintjs folder.

c. The complete path of the file should be : libraries/fingerprint/fingerprint2.js

To configure the module go to /admin/config/system/google-analytics-cookieless.

Similar modules

The Google Analytics module has more features but does not come (yet) with a Cookieless feature.

Configuration

FingerprintJS library does not come with a minified version by default. It is possible to use a CDN version or to build a compiled one with npm/yarn.
See : https://github.com/Valve/fingerprintjs2/issues/504

On a Drupal website, you can just enable JS aggregation on the performance page (admin/config/development/performance).

Drupal 8–10 · not 11

Ask your assistant about Google Analytics Cookieless

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Apr 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.1.0 Stable 8–10 Apr 27, 2023