Expand my Community achievements bar.

SOLVED

Adobe Client Data Layer with AEM Core Components - Expose dataLayer using JSON Exporter

Avatar

Level 5

we are extending core components and have added custom attributes in the data layer.

however, we want to export the data layer object for the component as part of JSON (.model.json)

 

currently the .model.json is not exposing the data layer object.

https://experienceleague.adobe.com/docs/experience-manager-65/content/implementing/developing/compon...

 

how can we expose the data layer object as part of JSON exporter for core/custom components?

@aanchal-sikka@arunpatidar, @Saravanan_Dharmaraj, @EstebanBustamante@Rohan_Garg 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@aem_noob - I am not sure why getDataLayer() method is not being exposed in the sling model but as discussed if use any custom method name such as getCustomData() that is working. For extending getData() you must necessarily return Component Data and not String.

I will try to find the reason for getDataLayer() but meanwhile you can use the below approaches-

  1. Override getData() returning Component Data object.
  2. Use custom method name

Hope this helps!

View solution in original post

10 Replies

Avatar

Level 5

@arunpatidar- the data layer is correctly showing the custom attributes which are added by extended the core components, the query was with respect to the component exporter JSON.

Avatar

Community Advisor

@aem_noob - Can you share the code for the sling model?

To extend the adobe client data layer, your custom sling model might have a getData method that returns an object that extends ComponentData to return more fields.

Please refer Extending the Adobe Client Data Layer


Other Reference Links-
https://medium.com/@abhaymishra12/customizing-adobe-client-data-layer-during-adobe-analytics-impleme...

https://experienceleague.adobe.com/docs/experience-manager-learn/sites/integrations/adobe-client-dat...

Avatar

Level 5

we're not using overlay of getData as that should return ComponentData. As https://experienceleague.adobe.com/docs/experience-manager-learn/sites/integrations/adobe-client-dat... states we used below snip-

aem_noob_0-1705595704868.png

can you please check inbox for the code?

Avatar

Correct answer by
Community Advisor

@aem_noob - I am not sure why getDataLayer() method is not being exposed in the sling model but as discussed if use any custom method name such as getCustomData() that is working. For extending getData() you must necessarily return Component Data and not String.

I will try to find the reason for getDataLayer() but meanwhile you can use the below approaches-

  1. Override getData() returning Component Data object.
  2. Use custom method name

Hope this helps!

Avatar

Level 5

update on getDataLayer() please - this should not be causing the issue

Avatar

Level 5

@Raja_Reddymy  issue is that the component exporter is not exposing the data layer object while the adobe data layer is correctly capturing it

Avatar

Administrator

@aem_noob Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 5

the discussion is still ongoing, i will mark the correct answer as soon as we get the fix