Matomo Tag Manager Ecommerce Data Layer Setup

Hey,

I try to setup E-Commerce Tracking manually with Datalayer and the Matomo Tag Manager for a Wordpress / Woocommerce Site. I followed the four steps of the faq: "https://matomo.org/faq/tag-manager/faq_35847/ . In the preview Mode the tag is fired and I can see the Trigger, Variables and Datalayer. However, I don’t get the Ecommerce Data in Matomo Analytics.

I followed the exact steps of 1-3. and adjusted the code of step 4 within my functions.php:

// Send Ecommerce Data to Matomo
function track_order_in_matomo( $order_id ) {
    // Get the order object
    $order = wc_get_order( $order_id );
    if ( ! $order ) {
        return;
    }

    // Get the order details
    $order_id = $order->get_order_number();
    $revenue = $order->get_total();
    $order_subtotal = $order->get_subtotal();
    $tax = $order->get_total_tax();
    $shipping = $order->get_total_shipping();
    $discount = $order->get_discount_total();

    // Push the data to Matomo
    echo '<script>
        window._mtm = window._mtm || [];
        window._mtm.push({
            \'event\': \'purchase\',
            \'ecommerce\': {
                \'purchase\': {
                    \'id\': \'' . $order_id . '\',
                    \'revenue\': ' . $revenue . ',
                    \'orderSubTotal\': ' . $order_subtotal . ',
                    \'tax\': ' . $tax . ',
                    \'shipping\': ' . $shipping . ',
                    \'discount\': ' . $discount . '
                }
            }
        });
    </script>';
}
add_action( 'woocommerce_thankyou', 'track_order_in_matomo' );

// Matomo Tag Manager Snippet in all header
function add_matomo_tag_manager_snippet() {
    echo '<!-- Matomo Tag Manager -->
          <script>
          var _mtm = window._mtm = window._mtm || [];
          _mtm.push({\'mtm.startTime\': (new Date().getTime()), \'event\': \'mtm.Start\'});
          var d=document, g=d.createElement(\'script\'), s=d.getElementsByTagName(\'script\')[0];
          g.async=true; g.src=\'https://analytics.monokelberlin.de/js/container_myid.js\'; s.parentNode.insertBefore(g,s);
          </script>
          <!-- End Matomo Tag Manager -->';
}
add_action( 'wp_head', 'add_matomo_tag_manager_snippet' ); Ecommerce is enabled in the Matomo Settings.

Would be very thankful for support.

hi @Bilal

Where do you check? In the real time log or in any other report?
Can you check if an HTTP request is sent by your browser wen tracking? Is the request response 200 or 204? Is there any error in the browser console log? Can you share the tracking HTTP request?