This repository was archived by the owner on Sep 28, 2023. It is now read-only.

Description
This plugin could automatically add revenue tracking for some of the largest WordPress e-commerce plugins like WooCommerce & Easy Digital Downloads.
It's a small amount of code and could make revenue tracking so much easier. Here's a snippet how one website set's it up.
function eddwp_optimizely_revenue_tracking() {
if( ! function_exists( 'edd_get_purchase_session' ) ) {
return;
}
if( function_exists( 'edd_is_success_page' ) && ! edd_is_success_page() ) {
return;
}
$session = edd_get_purchase_session();
if( ! $session ) {
return;
}
$payment_id = edd_get_purchase_id_by_key( $session['purchase_key'] );
?>
<script>
var price = <?php echo edd_get_payment_amount( $payment_id ); ?>;
window.optimizely = window.optimizely || [];
window.optimizely.push(['trackEvent', 'purchase_complete', {'revenue': price * 100}]);
</script>
<?php
}
add_action( 'wp_head', 'eddwp_optimizely_revenue_tracking', 11 );
From: https://github.com/easydigitaldownloads/edd-custom-functions/blob/master/custom-functions.php#L150-L173