How to add Data Layer | Community
Skip to main content
AEM_Forum
March 26, 2024
Solved

How to add Data Layer

  • March 26, 2024
  • 1 reply
  • 1463 views

Hi all,

 

I understand Data Layer is a JS Object that should be on the web page to collect events, etc and pass to Adobe Launch.

 

But a typical AEM implementation will have multiple pages.

 

How to add this Data Layer to each of these pages?

 

I highly appreciate all your replies.

 

Thanks,

RK.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mahesh_Gunaje

Hi Harwinder,

 

I went through multiple URLs but could not get it.

 

Trying to understand at a high level on how it should be done.

 

And my questions are pretty much pointed ones.

 

So, if you could answer in laymen's terms, it helps me a lot.

 

1.Where is Data Layer placed physically?

2.Where do we add this statement?  Base template?

window.adobeDataLayer = window.adobeDataLayer || [];.

3.We do not get to see Adobe Data Layer?

4. Data Later is basically to catch events and pass this info to Tag Manager?

 

Thanks,

RK.


Hi @aem_forum 

 

You can refer this article to know : How to create data layer:

https://medium.com/@toimrank/adobe-analytics-data-layer-1cf2c9b187a7

To your queries

1: Where is Data Layer placed physically: The script will be part of page component. So, this will be available in each AEM page.

2: Where do we add this statement?  Base template:  Script is placed in Base page template.

3: 3.We do not get to see Adobe Data Layer? :  Check the View Page source.

 

4. Data Later is basically to catch events and pass this info to Tag Manager?: Yes.  Once you keep the Adobe Launch script in the language page properties section. This script will execute during every page load time. This reads your Data layer details and pass it to Adobe Analytics.

Note: By default Adobe Launch script is placed in Akamai CDN.

 

 

1 reply

Harwinder-singh
Community Advisor
Community Advisor
March 26, 2024

@aem_forum  Add the JS that Initializes your data layer object in the root/base page template so that this object is available in all AEM pages.

AEM_Forum
AEM_ForumAuthor
March 26, 2024

Thanks Harwinder.

 

Where is Data Layer placed physically?

 

What is the JS that Initializes the data layer object and how to add it in the root/base page template?

How does this JS refer to the actual Data Layer?

 

Thanks,

RK.

 

Harwinder-singh
Community Advisor
Community Advisor
March 26, 2024

@aem_forum The initializing code should look something like this : 

 window.adobeDataLayer = window.adobeDataLayer || [];.

 

More details on setup - https://experienceleague.adobe.com/en/docs/experience-manager-learn/sites/integrations/adobe-client-data-layer/data-layer-overview