Created
June 29, 2015 17:42
-
-
Save devinsays/3d8ccc69a1f433bc6f88 to your computer and use it in GitHub Desktop.
Example of WooCommerce Conversion Tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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