Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.