WooCommerce: Difference between revisions

From Growth Agency Wiki
Jump to navigation Jump to search
Created page with " = Tracking = Would advise to use the duracelltomi plugin instead!!!!!! == Tracking URL == /checkout/order-received/ == Tracking via hook == goes in theme's function.php..."
 
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
= Tracking =
= Tracking =


Would advise to use the duracelltomi plugin instead!!!!!!
Would advise to use the [[Google Tag Manager for WordPress (Plugin)]] instead!


== Tracking URL ==
== Tracking URL ==
Line 17: Line 17:
function wc_value_tracking( $order_id ) {
function wc_value_tracking( $order_id ) {


  $order = new WC_Order( $order_id );
$order = new WC_Order( $order_id );
  $order_total = $order->get_total();
$order_total = $order->get_total();
  echo "<script>dataLayer.push({'order_id' : '<?php echo $order_id ?>', 'order_value' : '<?php echo $order_total ?>', 'event' : 'order-submitted'});</script>";


?>
<script>dataLayer.push({'order_id' : '<?php echo $order_id; ?>', 'order_value' : '<?php echo $order_total; ?>', 'event' : 'order-submitted'});</script>";
<?php
}
}
</pre>
</pre>

Latest revision as of 16:38, 1 December 2020

Tracking

Would advise to use the Google Tag Manager for WordPress (Plugin) instead!

Tracking URL

/checkout/order-received/

Tracking via hook

goes in theme's function.php

add_action( 'woocommerce_thankyou', 'wc_value_tracking', 50 );

function wc_value_tracking( $order_id ) {

	$order = new WC_Order( $order_id );
	$order_total = $order->get_total();

	?>
	<script>dataLayer.push({'order_id' : '<?php echo $order_id; ?>', 'order_value' : '<?php echo $order_total; ?>', 'event' : 'order-submitted'});</script>";
	<?php
}

Feed

If the client is using the official woocommerce feed plugin this can be checked by using the query parameter:

www.example.co.uk/?woocommerce_gpf=google

extra GET variables for use:

&gpf_start=0
&gpf_limit=100