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

Add Revenue Tracking #25

@BFTrick

Description

@BFTrick

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions