Expand my Community achievements bar.

Elevate your expertise and be recognized as a true influencer! Nominations for the exclusive Adobe Community Advisor program 2023 are now OPEN.
SOLVED

Disable Data-Layer at Component Level

Avatar

Level 4

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!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

Avatar

Community Advisor

@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.

Avatar

Level 4

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?

Avatar

Correct answer by
Community Advisor

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.