• Resolved steramon

    (@steramon)


    Hello,
    I noticed that for ecommerce is not possibile to track the “ViewCategory” event, or I can’t find it. Is it possible to set it up somehow or am I missing some steps?

    I think that it would be very useful to add this option into the “Track this eCommerce Conversions” section.

    Thank you so much, keep up with the great work!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Antonino Scarfì

    (@antoscarface)

    Hi,

    unfortunately, the event is not supported by the plugin yet, but I wrote you a little code to enable it manually. I tested on my end and it seems to work good. Here it is:

    
    add_action(
    	'template_redirect',
    	function() {
    		if ( is_product_category() ) {
    			global $wp_query;
    
    			$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    
    			$product_ids = array_values(
    				array_map(
    					function( $item ) {
    						return $item->ID;
    					},
    					$wp_query->posts
    				)
    			);
    
    			AEPC_Track::track(
    				'ViewCategory',
    				array(
    					'content_type'     => 'product',
    					'content_name'     => $term->name,
    					'content_category' => $term->name,
    					'content_ids'      => array_slice( $product_ids, 0, 10 ),
    				)
    			);
    		}
    	}
    );
    

    Please, copy this code and paste it in your installation in, in one of these two ways:

    Thread Starter steramon

    (@steramon)

    Thank you so much!
    I tested it and works perfectly ??

    Plugin Author Antonino Scarfì

    (@antoscarface)

    Awesome!

    Anyway, I’m adding this also in the next release (it will be released today or tomorrow at most). So, remember to remove this code when you will upgrade, otherwise you will occur in double ViewCategory pixels.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ViewCategory Event Tracking’ is closed to new replies.