Product impression on newly appended product not working
-
First of all, I would like to express my appreciation for the excellent features and functionality that the plugin offers for managing GTM.
Recently, I have implemented infinite scroll on my search page. But when doing weekly test I noticed something.
I am using the EEC event for product impression. And discovered after I implemented infinite scroll that it doesn’t track newly appended products. And the span element that has class gtm4wp_productdata I use to get product details for GTM is not there. The products that initialy loaded all work (impression and
span
class are there).I could just use element visibility but that important part is the
span
element that has details of the product is not there on the newly appended products.This is the AJAX function I’m using if that’ll help
function load_more_products_archive_page(){ $offset = $_POST['offset']; $curr_query = $_POST['query']; $default_args = array( 'post_type' => 'product', 'posts_per_page' => 12, 'offset' => $offset, ); $args = wp_parse_args($curr_query, $default_args); $loop = new WP_Query($args); ob_start(); if($loop->have_posts()) { while($loop->have_posts()) { $loop->the_post(); wc_get_template_part('content', 'product-list'); } } wp_reset_postdata(); $response = ob_get_clean(); echo $response; wp_die(); }
Thanks again!
- The topic ‘Product impression on newly appended product not working’ is closed to new replies.