Adding google analytics ecommerce tracking to woocommerce

I need to add the google analytics ecommerce tracking to a wordpress site with woocommerce.

I understand I need to add the code for tracking and on this page https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce it says I need to add some codes to a thank you page.

Read More

I’ve tried adding these codes via a
add_action( 'woocommerce_thankyou', 'my_custom_tracking' );
but in most cases I get some php error or it doesn’t work.

Also, I’ve tried google ecommerce integration plugin but it didn’t work.

What part of the GA ecommerce tracking code do I need to add and where to be able to track conversions on google analytics ?

Related posts

1 comment

  1. First You need to add analytics tracking code in the footer. You can do that like this:

    <?php
    function your_function() {
       echo '<p>This is inserted at the bottom</p>';
    }
    add_action( 'wp_footer', 'your_function' );
    ?>
    

    Then you need to add conversion tracking code, You can do that by editing your theme’s thankyou.php page

Comments are closed.