Articles on: Magento 2 Pearl Theme User Guide

How to solve compatibility issues - Google Tag Manager Enhanced eCommerce and Google Analytics 4

If you’ve installed Google Tag Manager Enhanced eCommerce or Google Analytics 4 and your product grid breaks or actions aren’t tracked (e.g., product view, add to cart, checkout), the cause is usually a compatibility conflict with a custom theme or a 3rd-party extension that alters Magento’s default templates/blocks.


We guarantee full compatibility with default Magento 2 and our Pearl Theme. Other themes may customize category/product listing templates, requiring small adjustments.



Quick fix that resolves ~95% of cases


If you’re using a customized theme (not Pearl/Luma), apply the steps below to prevent layout overrides while keeping click tracking.



A) Google Tag Manager Enhanced eCommerce (Universal Analytics)


1) Disable the layout rewrite from the GTM module

Edit: app/code/WeltPixel/GoogleTagManager/view/frontend/layout/default.xml

Comment out the category/product listing template rewrite (the portion highlighted in your screenshot):


Disable GTM layout rewrite


2) Add product click tracking into your theme’s listing template

Open your custom product listing template (usually list.phtml) and inject the click tracking on the product image <a> element.


  • Add the GTM helper attribute:


<?php echo $this->helper('WeltPixel\GoogleTagManager\Helper\Data')->addProductClick($_product, $iterator-1); ?>


  • Replace the original Magento image link (example):


Original:

<?php // Product Image ?>

<a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">

<?php echo $productImage->toHtml(); ?>

</a>


Updated (note the helper printed inside the <a ...> tag):

<?php // Product Image ?>

<a <?php echo $this->helper('WeltPixel\GoogleTagManager\Helper\Data')->addProductClick($_product, $iterator-1); ?>

href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>"

class="product photo product-item-photo"

tabindex="-1">

<?php echo $productImage->toHtml(); ?>

</a>


3) Deploy changes

  • Save/upload files
  • Clear caches (and deploy static content if needed)



B) Google Analytics 4 (GA4)


1) Disable the layout rewrite from the GA4 module

Edit: app/code/WeltPixel/GA4/view/frontend/layout/default.xml

Comment out the listing template rewrite (as in your screenshot):


Disable GA4 layout rewrite


1a) (PRO only) Using Click Tracking via Measurement Protocol (Server-Side)

Extend the file:


  • From: app/code/WeltPixel/GA4/view/frontend/layout/weltpixel_ga4_serverside_select_item.xml
  • To: app/design/frontend/<your_theme_vendor>/<your_theme>/WeltPixel_GA4/layout/override/base/weltpixel_ga4_serverside_select_item.xml


Then clear the XML body (leave an empty layout container so it no longer rewrites your listing):


Create override file path

Empty XML body


2) Add GA4 product click tracking into your theme’s listing template

Open your custom list.phtml and adjust the Product Image link:


<?php $ga4Helper = $this->helper('WeltPixel\GA4\Helper\Data'); ?>


<?php // Product Image ?>

<a <?php if ($ga4Helper->isProductClickTrackingEnabled()) :

echo $this->helper('WeltPixel\GA4\Helper\Data')->addProductClick($_product, $iterator-1);

endif; ?>

href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>"

class="product photo product-item-photo"

tabindex="-1">

<?php echo $productImage->toHtml(); ?>

</a>


3) Deploy changes

  • Save/upload files
  • Flush caches (and deploy static assets if applicable)



If issues persist

The above fixes address the majority of conflicts. If your theme heavily customizes the Category/Product listing markup, a developer may need to adapt the snippet placement or adjust other blocks.



Consider an integrated, compatible starting point

If you’re early in the project, using an integrated solution can save time otherwise spent on compatibility work. The Pearl Theme includes Google Tag Manager, Quick View, Banner Slider, Instagram Widget, and more — all compatible out of the box:

https://www.weltpixel.com/magento-2-theme-pearl



Example: Category Page conflict resolution


Problem (summary): After installing the GTM extension, the theme’s category product grid appearance changed due to a template override conflict.


Files adjusted:

  • app/code/WeltPixel/GoogleTagManager/view/frontend/layout/default.xml

(Removed the category product listing template rewrite)

  • app/design/frontend/Infortis/ultimo/Magento_Catalog/templates/product/list.phtml

(Added the GTM product click helper to the image link)


Note: We don’t have a universal, conflict-free solution for all themes that customize Category Page layouts. Minor adjustments by a developer may be necessary depending on your theme’s structure. Community suggestions are welcome.

Updated on: 16/09/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!