Disable Data-Layer at Component Level | Community
Skip to main content
New Participant
February 25, 2023
Solved

Disable Data-Layer at Component Level

  • February 25, 2023
  • 1 reply
  • 1708 views

Hello Everyone!

 

Is it possible to disable the data-layer at component level? I am aware of the configuration which disable the data-layer for entire project but we don't want that. We want to disable data-layer for only specific components. Especially core component as they all comes with data-layer functionality added to them. Our Analytics team is complaining saying that they are seeing lots of data getting pushed to data-layer that are not necessary, like text, title component etc.

 

Thank you!

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 HeenaMadan

There is no OOTB method to disable datalayer at component level as 

com.adobe.cq.wcm.core.components.internal.DataLayerConfig

would be applicable per project.

You can customize your component and add check enablement of datalayer at dialog level with default false and proide priority if component DL is false then disable otherwise project specific datalaterconfig value would be used.

1 reply

Jagadeesh_Prakash
New Participant
February 26, 2023

@webdev91 

The  data layer can be disabled for specific components by modifying the component's implementation. Here's how you can disable the data layer for specific components:

  1. Locate the component implementation in AEM's repository. This is typically stored in the /apps or /libs folder, depending on whether it is a custom or out-of-the-box component.

  2. Edit the component's JavaScript file to disable the data layer. This can be done by commenting out or removing the code that sends data to the data layer.

  3. If necessary, update the component's Sightly or JSP file to remove any references to the data layer. For example, you may need to remove data layer variables or data-attributes that are used to populate the data layer.

  4. Save your changes and test the component to ensure that the data layer is no longer being used.

Here's an example of how you might disable the data layer for a specific component in AEM's TouchUI:

(function() {
var component = document.querySelector('.my-component');
if (component) {
// Comment out the code that sends data to the data layer
// window.adobeDataLayer.push({
// 'event': 'componentView',
// 'component': 'my-component',
// 'page': window.location.href
// });

// Remove any data layer variables or data-attributes
// component.dataset.adobeAnalytics = null;
}
})();

In this example, the data layer code has been commented out and the data layer attribute has been removed from the component.

Overall, disabling the data layer for specific components can help to reduce data volume and simplify data layer management. However, you should carefully consider the impact of disabling the data layer for each component and ensure that you are still able to collect the necessary data for your analytics and reporting needs.

webdev91Author
New Participant
February 27, 2023

Hi @jagadeesh_prakash 

Thanks for responding.

Do you know of any other method than customizing the core components code? Like 

 

/conf/my-project/sling:configs/com.adobe.cq.wcm.core.components.internal.DataLayerConfig

 

 this configuration which enables data-layer at the project level. Is there anything like this at component level?

HeenaMadan
HeenaMadanAccepted solution
New Participant
February 27, 2023

There is no OOTB method to disable datalayer at component level as 

com.adobe.cq.wcm.core.components.internal.DataLayerConfig

would be applicable per project.

You can customize your component and add check enablement of datalayer at dialog level with default false and proide priority if component DL is false then disable otherwise project specific datalaterconfig value would be used.