Impressions & Clicks

Enhanced Ecommerce : Click and Impressions configuration

Note

These modifications are optional! Without it, you will just not have impressions & clicks informations.

You will need to add some modification to your theme if you want to benefit fully the Enhanced Ecommerce plugin. You will find on this page the documentation to manage Product Impressions, Product clicks, Promotion Impressions and Promotions clicks

Product click & impression tracking

You’ll have to use the ViewModel Webcooking\GoogleAnalytics4\ViewModel\Impressions whenever a link to a product view is displayed. For example, you’ll want to start with catalog/product/list.phtml template.

To track a product clicks, you’ll have to add this code :

<?= /* @noEscape */ $impressionViewModel->getProductLinkData($_product) ?>

The parameters of getProductLinkData method are :

  1. The product. Required. This must be a ‘catalog/product’ model.

  2. The list name. Optional. If you leave it to false, our extension will try to guess a list name. For example : “Category Electronics Product List”.

  3. The list ID. Optional. If you leave it to false, our extension will try to guess a list name. For example, the category ID.

  4. The position of the product on the list. Optional. On list.phtml template, you will want to use $_iterator variable for list mode, and $i for grid mode.

You have to place this code whenever a link product is displayed in a list, inside the <a> tag, for example :

<a <?= /* @noEscape */ $impressionViewModel->getProductLinkData($_product) ?>
href="<?= $escaper->escapeUrl($_product->getProductUrl()) ?>"
               class="product photo product-item-photo"
               tabindex="-1">

Promo click & impressions tracking

You’ll have to add a PHP code whenever a link to a promo is displayed.

To track a promo clicks, you’ll have to add this code :

<?= /* @noEscape */ $impressionViewModel->getPromoLinkData('PROMO12', 'Summer Sale', 'sbanner2', 'banner_slot1') ?>

The parameters of getPromoLinkData method are :

  1. The promotion ID. Required.

  2. The promotion name. Optionnal.

  3. The creative associated with the promotion (e.g. summer_banner2).

  4. The position of the promotion. Optionnal.

You have to place this code whenever a link to promo is displayed, inside the <a> tag, for example :

<a <?= /* @noEscape */ $impressionViewModel->getPromoLinkData('PROMO12', 'Summer Sale', 'sbanner2', 'banner_slot1') ?>
href="<?php echo $this->getUrl('promotions') ?>" title="<?php echo $this->__('Summer Sales !'); ?>">

Finally, we are sorry to put your hands into the code, it should be our job! However, we cannot detect all your promotions, and product’s impressions/links :) Especially since you have a very customized (and so beautiful) theme, right ?

We hope our extension will help you in your business! Cheers!