This project is an implementation of the Customer Experience Digital Data Layer 1.0 specification produced by the W3C.
It provides a flexible, extensible model for implementers to create a Data Layer in Adobe Experience Manager by implementing clean, reusable Java code.
The main parts of the template are:
The goal of this project is to create an easily extensible, flexible API for exposing CMS data to Digital Marketing tools. In order to use the AEM DataLayer on your project, you must create Sling Models to expose data to the DataLayer based on your needs.
The AEM DataLayer is compatible with AEM versions 6.3 and 6.2. To install this project on AEM, download the latest release and install it into the AEM Package Manager.
The AEM DataLayer requires Sling Models API version 1.3.2 or more recent. In order to install AEM DataLayer on AEM 6.2, you must download and install the following bundles:
To get started, you may want to review the weretail-reference project to get a better idea of how to implement the AEM DataLayer for your project.
The implementation process is pretty simple, you simply create Sling Models for each component you want to use to populate your DataLayer. Each Sling Model should implement the interface ComponentDataElement and specify a resource type as shown below:
@Model(adaptables = Resource.class, resourceType = {
"weretail/components/structure/page" }, adapters = ComponentDataElement.class)
public class DefaultPageDataElement implements ComponentDataElement {
As this is a Sling Model, you can inject any OSGi Service, Resource property or the Resource itself into your Model class.
The ComponentDataElement#updateDataLayer method will be called by the AEM DataLayer API when your Sling Model is adapted from a Resource in order to update the DataLayer.
Your ComponentDataElement model can also be adapted from a SlingHttpSerlvetRequest. This will allow you to access any Request parameters or attributes. Simply specify the adaptable SlingHttpSerlvetRequest
in your Sling Model definition.
@Model(adaptables = SlingHttpSerlvetRequest.class, resourceType = {
"weretail/components/structure/page" }, adapters = ComponentDataElement.class)
public class DefaultPageDataElement implements ComponentDataElement {
And then use the @Self
annotation to inject the SlingHttpSerlvetRequest
as a private class variable.
Once you have installed the AEM DataLayer package, you can set up and configure it as such:
From here, your page should automatically include the DataLayer. You can use the test feature to validate that your custom DataLayer classes are being evaluated.
To build all the modules run in the project root directory the following command with Maven 3:
mvn clean install
If you have a running AEM instance you can build and package the whole project and deploy into AEM with
mvn clean install -PautoInstallPackage
Or to deploy it to a publish instance, run
mvn clean install -PautoInstallPackagePublish
Or to deploy only the bundle to the author, run
mvn clean install -PautoInstallBundle
There are three levels of testing contained in the project:
unit test in core: this show-cases classic unit testing of the code contained in the bundle. To test, execute:
mvn clean test
server-side integration tests: this allows to run unit-like tests in the AEM-environment, ie on the AEM server. To test, execute:
mvn clean integration-test -PintegrationTests
The release process is as follows:
mvn clean install
mvn versions:set -DnewVersion=[new-version]
git commit -a -m "Updating to release version [new-version] && git push"
git tag [new-version] && git push origin [new-version]
mvn deploy
mvn versions:set -DnewVersion=[new-snapshot]
git commit -a -m "Updating to snapshot version [new-snapshot] && git push"