I'm using magento2.4.2 and added catalog widget in homepage.Need to add datalayer to addtocart event in MagentoCatalogWidgets. Note:Add to cart event for listing and detail pages are working perfectly


1 Answer 1


the first thing to understand with widget is that the template they use can be configured differently from the pagebuilder, on the screenshot below, we can see the template is: Magento_CatalogWidget::product/widget/content/grid.phtml (full path: vendor/magento/module-catalog-widget/view/frontend/templates/product/widget/content/grid.phtml)

enter image description here

To customise this template, we know we may add a new file in the folder app/design/frontend/Vendor/ThemeName/Magento_CatalogWidget/product/widget/content/grid.phtml

Once we have this template in the right place, then adding datalayer feature will lead to have the same changes as what was done on other templates.

  • Im using enterprise,so for all other templates that was added by default ..but not in widget Aug 17, 2022 at 14:56
  • my answer is based on an enterprise environment as well Aug 17, 2022 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.