Set up SEO for WooCommerce

1. Create Standard Tag Manager
2. Add new tag for ecommerce – call ‘GA Conversion Tracking’

See Example
SEO for WooCommerce

SEO for WooCommerce

3. Add code for track ecommerce tracking on function.php

See Example

// 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&amp;label=fUR8CLmnngoQv_DytgM&amp;guid=ON&amp;script=0″/>
</div>
</noscript>

<?php }

add_action( ‘woocommerce_thankyou’, ‘ia_wc_ga_integration’ );

 

4. Then do normal goal and ecommerce on analytics

More
Addresses
Contact Us
Intouch
newsletter
© 2024 Imarketingonly All rights reserved.

Imarketingonly

The Great Oast, Steep Marsh Petersfield Hampshire GU32 2BN
125/5A Srisoonthorn Road. Cherngtalay District. Thalang Phuket 83110
+66 (0) 76 324184 +66(0) 898 740 040 +44 (0) 1730 895648 +44 (0) 208 1234 164 +44 (0) 7798 554540 Start Price 120 GBP