Skip to content

Instantly share code, notes, and snippets.

@devinsays
Created June 29, 2015 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devinsays/3d8ccc69a1f433bc6f88 to your computer and use it in GitHub Desktop.
Save devinsays/3d8ccc69a1f433bc6f88 to your computer and use it in GitHub Desktop.
Example of WooCommerce Conversion Tracking
function prefix_service_conversion_tracking( $order_id ) {
// Lets grab the order
$order = new WC_Order( $order_id );
// Order ID
$order_id = $order->get_order_number();
// Order total
$order_total = $order->get_total();
// Order e-mail
$order_email = $order->billing_email;
?>
<script>
window['service'] = window['service'] || [];
window['service'].push(['track', 'order',
{
order_id : '<?php echo $order_id; ?>',
order_total: '<?php echo $order_total ?>',
order_email: '<?php echo $order_email ?>'
}
]);
</script>
<?php
}
add_action( 'woocommerce_thankyou', 'prefix_service_conversion_tracking' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment