Skip to content

Commit

Permalink
Fix: add_to_cart tracked with variable and grouped products in lists
Browse files Browse the repository at this point in the history
  • Loading branch information
duracelltomi committed Apr 2, 2024
1 parent c682f0e commit 8e71bec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions integration/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ function gtm4wp_woocommerce_get_product_list_item_extra_tag( $product, $listtype
'productlink' => $permalink,
'item_list_name' => $list_name,
'index' => (int) $itemix + ( $posts_per_page * ( $paged - 1 ) ),
'product_type' => $product->get_type(),
),
'productlist'
);
Expand Down
8 changes: 6 additions & 2 deletions js/gtm4wp-woocommerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,15 @@ function gtm4wp_woocommerce_process_pages() {
if ( !productdata ) {
return true;
}


if ( "variable" === productdata.product_type || "grouped" === productdata.product_type ) {
return true;
}

if ( productdata.productlink ) {
delete productdata.productlink;
}

delete productdata.product_type;
productdata.quantity = 1;

gtm4wp_push_ecommerce( 'add_to_cart', [ productdata ], {
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ to report micro conversions and/or to serve ads only to visitors who spend more
= 1.20.2 =

* Fix: Wrong ID parameter used tracking product variations (id instead of item_id). Thanks [micmaf](https://github.com/micmaf)
* Fix: do not track add_to_cart in product lists when 'Select options' or 'View products' buttons are clicked

= 1.20.1 =

Expand Down

0 comments on commit 8e71bec

Please sign in to comment.