Push custom metric only on purchase event
-
Hi,
I configured a custom metric (product scoped) in my GA account that should hold the purchase price of any product.
add_filter(‘gtm4wp_eec_product_array’, ‘inbound_gtm_product’);
function inbound_gtm_product($array)
{
$product = get_product($array[‘id’]);
// cost of goods
$array[‘metric1’] = get_post_meta($array[‘id’], ‘yith_cog_cost’, true);
return $array;
}I managed to push this to GA with the code above but the issue I’m having is that it’s also pushing when the product is viewed/added to cart. So it get’s included in my profit calculation although a purchase didn’t happen.
Is there a way to only set this custom metric on the purchase event?
Kind regards
- The topic ‘Push custom metric only on purchase event’ is closed to new replies.