AddToCart Pinterest Tracking with WooCommerce

Viewed 27

I need help with the Pinterest Tracking for the Cart Value in WooCommerce. I want to track dynamically the Items, Quantity and Total.

I'm stuck to write the Code:

add_action( 'woocommerce_add_to_cart', 'pinterest_tracking' );

function pinterest_tracking($cart_total) {

$cart_total = $woocommerce->cart->cart_contents_total;

?>

<script>
    pintrk('track', 'AddToCart', {
        {
            value: '<?php echo $cart_total ?>',
            currency: 'EUR'
        }
    ]);
</script>
<noscript>
<img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=TRACKID&event=AddToCart&ed[value]=<?php echo $order_total ?>&noscript=1"/>
</noscript>
<?php

}
0 Answers
Related