• Hi, I need to know if it is possible to track the wishlist contents in Google Analytics.
    The purpose is to know which products are most appreciated and most interesting.
    Thank you, have a good day.
    Roberta

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi Roberta

    You definitely can, but it will require some custom coding
    Here a reference to Google documentation on how to track custom events on your site

    In this case you’ll need to track Add to Wishlist event; in order to do so, you’ll need to listen for added_to_wishlist event, as such

    jQuery(document).on( 'added_to_wishlist', function( ev, t ) {
        let product_id = parseInt( t.attr( 'data-product-id' ) );
        ga( 'send', {
            hitType: 'event',
            eventCategory: 'Wishlist',
            eventAction: 'add',
            eventValue: product_id
        } );
    } );
    

    Of course you’ll need to include this snippet in your page (you can use wp_add_inline_script for this) and make sure that GA library is already loaded (otherwise a js error will be triggered)
    Similar tracking could be done for Remove from wishlist (removed_from_wishlist event), if needed

    Thread Starter roberta04

    (@roberta04)

    Thank you for your reply.
    I will try it

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Track wishlist content’ is closed to new replies.