• Resolved Bill Karkavos

    (@bill-karkavos)


    WP 4.9.4 – WC 3.2.6

    Hello,
    this plugin works with no problem
    but since updating to WC 3+ I can see that in GA > E-commerce (Top Sellers)
    that the product titles now include the size attributes!

    So, before the update it was easy to see the Top Sellers by product title
    Product Title 1
    Product Title 2
    Product Title 3

    while now you see the product titles including size attributes which really makes it harder to understand your top seller in a Parent level straight away
    Product Title 1 – Size 6
    Product Title 1 – Size 8
    Product Title 2 – Size 6
    Product Title 2 – Size 10

    So would it be possible to show Top Sellers in GA with the product title only?
    (as it used to be)

    A note here that I have implemented the following snippet in functions.php in order to remove attributes from the product titles in the cart / checkout, which works great, but unfortunately does not seem to prevent this from happening in GA.

    
    /**
     * Removes the attribute from the product title, in the cart.
     */
    function remove_variation_from_product_title( $title, $cart_item, $cart_item_key ) {
    	$_product = $cart_item['data'];
    	$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
    	if ( $_product->is_type( 'variation' ) ) {
    		if ( ! $product_permalink ) {
    			return $_product->get_title();
    		} else {
    			return sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_title() );
    		}
    	}
    	return $title;
    }
    add_filter( 'woocommerce_cart_item_name', 'remove_variation_from_product_title', 10, 3 );
    add_filter( 'woocommerce_is_attribute_in_product_name', '__return_false' );
    

    Any suggestions will be highly appreciated.

    Thank you in advance,

    Best,

    Bill

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Bill Karkavos

    (@bill-karkavos)

    Update >

    Hey all,

    I ve added the following

    
    
    function custom_woocommerce_is_attribute_in_product_name( ) {
    	return false;
    }
    add_filter( 'woocommerce_is_attribute_in_product_name', 'custom_woocommerce_is_attribute_in_product_name' );
    
    

    https://gist.github.com/madeincosmos/eab163f60d3ea84ea8660aa6a014c14d

    but this does not seem to resolve this.

    Any suggestions would be appreciated.

    Please let me know!

    Best,

    Bill

    Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Hi Bill,

    The last used snippet will remove the attributes from the site only, not what is sent to Google Analytics. In this case the entire product title is sent as shown here.

    In this case you’ll want to use the Enhanced Ecommerce features within Google Analytics to better sort the product data you’re looking for. More on that here:

    https://support.google.com/analytics/answer/6014872?hl=en#pp

    Thread Starter Bill Karkavos

    (@bill-karkavos)

    Hello @johndcoy,

    thank you for your reply.

    The thing is that I wanted a solution without dealing with sorting in GA

    Actually I have added the following snippet – and this seemed to do the trick – as now product titles in GA do not include size attributes

    
    /**
     * Removes all WooCommerce product attributes from product name in vars
     */
    add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );

    Do you find anything wrong in using this?

    Thank you!

    Best,

    Bill

    Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Hi @bill-karkavos

    Thanks for that! Looks simple enough and I don’t see this being a problem until you do want to see that information in Google Analytics. If later you do want to include that information, removing it would not reflect previous transactions.

    Thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove attributes from the product title in GA’ is closed to new replies.