Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

dataLayer

9,754 sites Security covered Drupal 10–11
View on drupal.org

This module exposes Drupal content, entity, and user data to the front-end. It outputs meta-data about pages, which can be used for various client-side features and is often integrated with tools like Google Tag Manager. The data is made available in a format that JavaScript can easily access and utilize.

Get content/entity/user data from inside Drupal to the client-side/front-end.

Outputs various CMS page meta data (like content type, author uid, taxonomy terms), which can be used for all kinds of front-end features. This works for all entity types and is easy to extend with hooks.

Documentation in the README

Often used for Google Tag Manager.

The "dataLayer" is just a front-end standard for passing info around, for example allowing your server-side to inform javascript behaviors. It enables plenty of 3rd party services (like Google Tag Manager) to access web application data. Regardless, you should use this juicy data to implement super-awesome-great client-side features, like... anonymous user tracking, etc.

NOTE: The dataLayer object is used as a warehouse for Google Analytics and GTM, and is therefor an array of objects. To safely access properties you should use the data-layer-helper library, a dependency of this module.

Some of what's exposed by default...

{
  "drupalLanguage": "en",
  "userUid": "555",
  "entityId" : "123",
  "entityLabel" : "My Cool Page",
  "entityType" : "node",
  "entityBundle" : "article",
  "entityUid" : "555",
  "entityTaxonomy" : {
    "my_vocab" : {
      "25" : "Term Name",
      "26" : "Another Term"
    }
  }
}

Access:

var myHelper = new DataLayerHelper(dataLayer);
myHelper.get('userUid');
myHelper.get('entityTaxonomy.my_vocab');

Add properties:

Example:

datalayer_add(array(
  'myProperty' => $value
));

See datalayer.api.php for more examples and options.

Bonus:

Provides front-end access to full-detail i18n language configurations, and a simple prefix list...

Drupal.settings.dataLayer.languages;
Drupal.behaviors.dataLayer.langPrefixes();

You'll need the Data Layer Helper library to manually access content client-side. Place that within your Libraries.

Need to create a custom dimension in GA GTM from taxonomy terms? Output is an object so you'll need this little code snippet.

Compatibility with Google Tag module

Due to a bug fix implemented in #3345817: Pages are uncacheable because of the cache context user version 2.0.1 of the dataLayer module is not compatible with Google Tag 8.x-1.6 or earlier. Use Google Tag version 2.0.2 or later. More information.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

4 tracked projects depend on this one

Activity

Tracked releases
2
Tracked since
Jan 2026
Latest release
7 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Slowing

Releases

Version Type Core Release date
2.1.2 Stable 10–11 Jan 20, 2026
2.1.1 Stable 10–11 Jan 15, 2026