Enhanced Ecommerce dataLayer WooCommerce
<p>I'm trying to set up a dataLayer for WooCommerce Thank you page. Look here what I've done so far (the variables are not completely set up yet): </p>

<pre><code>function dataLayer_google_gtm( $order_id ) {

    // Lets grab the order
    $order = wc_get_order( $order_id );

    // Products
    $products = $order-&gt;get_items();
    ?&gt;

    &lt;script&gt;
        dataLayer.push({
        'ecommerce': {
            'purchase': {
                'actionField':{
                    'id':'&lt;?php echo $order-&gt;get_order_number(); ?&gt;',
                    'affiliation':'CHACAFOODS', 
                    'revenue':'&lt;?php echo $order-&gt;get_order_total(); ?&gt;',
                    'tax':'&lt;?php echo $order-&gt;get_total_tax(); ?&gt;',
                    'shipping':'&lt;?php echo $order-&gt;get_shipping(); ?&gt;',
                    'coupon':'&lt;?php echo $order-&gt;get_order_discount_total(); ?&gt;',
                },
                window['service'].push('products':,[
                &lt;?php
                    $count = 0;
                    foreach( $products as $item_id =&gt; $item ) {
                        $count++;
                        $product = $order-&gt;get_product_from_item( $item ); ?&gt;
                        {
                            'name':&lt;?php echo $item['name']; ?&gt;',
                            'id':
                            'price': '&lt;?php echo $order-&gt;get_line_subtotal( $item ); ?&gt;',
                            'brand':
                            'category':
                            'variant':
                            'quantity': '&lt;?php echo $item['qty']; ?&gt;'
                        }
                &lt;?php if ( count( $order-&gt;get_items() ) &gt; $count ) { echo ","; } ?&gt;
                &lt;?php } ?&gt;
                ]);
            }
        }
        });
    &lt;/script&gt;
    &lt;?php
}
add_action( 'woocommerce_order_status_completed', 'prefix_service_conversion_tracking' );
</code></pre>

<p>Can anybody tell me if my structure above will look like the enhanced ecommerce structure below in result? </p>

<p>google dataLayer structure: </p>

<pre><code>&lt;script&gt;
// Send transaction data with a pageview if available
// when the page loads. Otherwise, use an event when the transaction
// data becomes available.
dataLayer.push({
  'ecommerce': {
    'purchase': {
      'actionField': {
        'id': 'T12345',                         // Transaction ID. Required for purchases and refunds.
        'affiliation': 'Online Store',
        'revenue': '35.43',                     // Total transaction value (incl. tax and shipping)
        'tax':'4.90',
        'shipping': '5.99',
        'coupon': 'SUMMER_SALE'
      },
      'products': [{                            // List of productFieldObjects.
        'name': 'Triblend Android T-Shirt',     // Name or ID is required.
        'id': '12345',
        'price': '15.25',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Gray',
        'quantity': 1,
        'coupon': ''                            // Optional fields may be omitted or set to empty string.
       },
       {
        'name': 'Donut Friday Scented T-Shirt',
        'id': '67890',
        'price': '33.75',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Black',
        'quantity': 1
       }]
    }
  }
});
&lt;/script&gt;
</code></pre>

<p>Thanks so much for your help!</p>

<p>Best regards, 
Anton</p>