1. Create Standard Tag Manager
2. Add new tag for ecommerce – call ‘GA Conversion Tracking’
3. Add code for track ecommerce tracking on function.php
// WooCommerce Google Analytics Integration
function ia_wc_ga_integration( $order_id ) {
$order = new WC_Order( $order_id );
?>
<script type=”text/javascript”>
dataLayer.push({
‘transactionId’: ‘<?php echo $order_id;?>’,
‘transactionAffiliation’: ‘<?php echo get_option( “blogname” );?>’,
‘transactionTotal’: <?php echo $order->get_total();?>,
‘transactionTax’: <?php echo $order->get_total_tax();?>,
‘transactionShipping’:<?php echo $order->get_total_shipping();?>,
‘transactionProducts’: [
<?php
//Item Details
$total_value=0;
$item_add=0;
if ( sizeof( $order->get_items() ) > 0 ) {
foreach( $order->get_items() as $item ) {
$product_cats = get_the_terms( $item[“product_id”], ‘product_cat’ );
if ($product_cats) {
$cat = $product_cats[0];
}
if($item_add>0)
{
?>
,
<?
}
$total_value = $total_value+$item[‘line_subtotal’];
?>
{
‘sku’: ‘<?php echo get_post_meta($item[“product_id”], ‘_sku’, true);?>’,
‘name’: ‘<?php echo $item[‘name’];?>’,
‘category’: ‘<?php echo $cat->name;?>’,
‘price’: <?php echo $item[‘line_subtotal’];?>,
‘quantity’: <?php echo $item[‘qty’];?>
}
<?php
$item_add=$item_add+1;
}
} ?>
]
});
</script>
<!– Google Code for Firefly Sale Conversion Page –>
<script type=”text/javascript”>
/* <![CDATA[ */
var google_conversion_id = 920434751;
var google_conversion_language = “en”;
var google_conversion_format = “3”;
var google_conversion_color = “ffffff”;
var google_conversion_label = “fUR8CLmnngoQv_DytgM”;
var google_conversion_value = <? echo $total_value;?>;
var google_remarketing_only = false;
/* ]]> */
</script>
<script type=”text/javascript” src=”//www.googleadservices.com/pagead/conversion.js”>
</script>
<noscript>
<div style=”display:inline;”>
<img height=”1″ width=”1″ style=”border-style:none;” alt=”” src=”//www.googleadservices.com/pagead/conversion/920434751/?value=20.00&label=fUR8CLmnngoQv_DytgM&guid=ON&script=0″/>
</div>
</noscript>
<?php }
add_action( ‘woocommerce_thankyou’, ‘ia_wc_ga_integration’ );
4. Then do normal goal and ecommerce on analytics