I feel that standards are a good thing. I think that each of us should strive to follow standard approaches, because it’ll make all of our lives easier. I also think that a Data Layer is an adornment on every site, and a svelte way of helping analysts and marketing do their work more flexibly.
Since pretty much every vendor in this world has also come up with their own standard (including Adobe with the ContextHub on AEM), the question is: why should I use CEDDL? The most important reason to me is: CEDDL is vendor-agnostic.
So today, let’s look at the best way to use CEDDL along with DTM, shall we?
First thing to do is to add the “AEM ContextHub” tool to your DTM Web Property.
Adding the tool means there’ll be a new Data Element type called “AEM ContextHub” in DTM. Those DEs allow your friendly marketer to select the data they want in a DE from a drop down, which is populated from the structure of the Data Layer.
By using those DEs, plus the “dataelementchanged” trigger, you can create Event-based Rules that fire when some (definable) part of the Data Layer changes, perfect for the
event structure in CEDDL.
The ContextHub tool was originally designed to work with the AEM ContextHub, as the name suggests. Luckily, the tool is flexible enough to work with any data layer structure, as long as you have a JSON Schema that describes your DL.
For CEDDL, you can find the schema (as you can so many other things) on github: CEDDL JSON Schema.
So let’s do this!
Start by clicking the “Add Tool” button on the “Overview” tab of your Web Property.
Select “AEM ContextHub” from the drop down (it should actually be selected), give your tool a name (like “Data Layer”), then click the “Create Tool” button.
On the AEM ContextHub Settings screen, you can decide whether you want to use the default AEM ContextHub data layer, or another structure. We’ll go for the latter, so select “[x] Customize ContextHub Data Layer”, tell it where to find the DL by typing
window.digitalData into the “Data Layer Root” field, then click the “Open Editor” button.
You’ll see a mostly black editor window with some code in it.
That code is the AEM data layer schema, and we need to replace it with a CEDDL-compatible schema.
Press CTRL-A or Command-A to select all code in the editor,
then hit your Backspace or Delete key.
Cool. We want that editor empty. Nice.
Next, get a CEDDL schema. There is one available on mkohlmyr’s github. You can jump straight to the raw code, then select all (CTRL-A on Windows, Command-A on Mac) and copy the lot (CTRL-C or Command-C).
Back in DTM, paste the schema code into the editor window (CTRL-V or Command-V).
Save the Tool, and we’re done here.
Now that we have the tool, we can use it to more easily define Data Elements.
As an example, let’s build a “Pagename” DE.
Head over to the “Rules” tab, then click “Data Elements” on the left. Now use the “Create Data Element” button.
Give your DE a name, say “Pagename”, then select “AEM ContextHub” in the Type drop down.
The dialog changes slightly now.
Note that there are two new drop down in the dialog window now:
- Source — if you have multiple DLs on your site (totally possible), this one lets you choose one of them
- Object — this drop down is where you pick an element from the DL, say
The “Object” drop down is what links the DE to the DL.
So select “page.pageInfo.pageName”, and you’re done.
CEDDL contains a sub-structure called “event”, which is meant to be dynamically populated as things happen on an already loaded page.
Each time something happens, there’ll be one more event added to the DL, along with some meta data that explains what happened.
For a cart add, as an example, that meta data would be a product ID, quantity, and maybe other data. For a login, it could be simply whether the login was successful, or why not, and so on.
We build a Data Element that points to the
event part of the DL, then we have an EBR listen to changes of that DE.
That allows us to properly handle interaction and dynamic changes on any page. Whether the EBR collects all data, determines the right events and “variables”, and tracks directly, or whether it works as a dispatcher, calling other EBRs or DCRs, is entirely up to you.
And that’s it. That’s how you use CEDDL with DTM.
(Btw: I think this article might be used beyond the usual developer audience, so that’s why I specified how to select, copy, and paste. HTH)