Expand my Community achievements bar.

SOLVED

Add data-cmp-data-layer-enabled attribute to body element

Avatar

Level 4

Hi all,

I need to add data-cmp-data-layer-enabled attribute to body element.

I follow the tutorial which creates /conf/<mySite>/sling:configs/com.adobe.cq.wcm.core.components.internal.DataLayerConfig.

And set the enabled property, added sling:configRef property under my site

 

However, I still couldn't see the attribute data-cmp-data-layer-enabled in body.

there's a thread with a reply suggested adding some javascript code on page.html, but I don't get what exactly should I do next.

 

Do you guys have any ideas about this?

I'm using aem 6.5.5 with com.adobe.granite.archetypes version 20

 

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @YuSheng,

The root cause off the issue is connect with core components version. Please be aware that data-cmp-data-layer-enabled attribute appears in page.html renderer has been exposed in core components 2.9.0. OOTB archetype version 20 provide 2.5.0 core components version. Here is the difference in the code:

As you can see 2.9.0 not only adds data-cmp-data-layer-enabled attribute but also additional section with JS code.

Summarizing, what you have to do to get it work, you should upgrade core components version to 2.9.0 or higher. I do not think you should do any changes in page.html, as it will not be so simple, because changes in page.html will require some changes on Sling models level as well to provide proper information that can be consumed on the page.html.

As an alternative solution you can generate project once again using never archetype version (24+)

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @YuSheng,

The root cause off the issue is connect with core components version. Please be aware that data-cmp-data-layer-enabled attribute appears in page.html renderer has been exposed in core components 2.9.0. OOTB archetype version 20 provide 2.5.0 core components version. Here is the difference in the code:

As you can see 2.9.0 not only adds data-cmp-data-layer-enabled attribute but also additional section with JS code.

Summarizing, what you have to do to get it work, you should upgrade core components version to 2.9.0 or higher. I do not think you should do any changes in page.html, as it will not be so simple, because changes in page.html will require some changes on Sling models level as well to provide proper information that can be consumed on the page.html.

As an alternative solution you can generate project once again using never archetype version (24+)

Avatar

Level 4

Thank you @lukasz-m 
I updated the archetype to latest (40) and the issue solved.