Open BFTrick opened 8 years ago
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
@BFTrick Going to test this on my end with the plugin and confirm if it causes any issues down the road or not.
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.
From: https://github.com/easydigitaldownloads/edd-custom-functions/blob/master/custom-functions.php#L150-L173