Set Up ShareASale Tracking Code For Easy Digital Downloads

Tips & Tricks

Set up an affiliate program is a popular and effective selling strategy and join an existing big affiliate network platform is absolutely the shortcut, it will save your time to looking for the affiliates by yourself. is one of the biggest affiliates networks, so if you already have an online shop which is based on Easy Digital Downloads and wants to set up an affiliate program on ShareASale, this guide will tell you how to set up the ShareASale tracking code for Easy Digital Downloads.

Set up an Affiliate program on ShareASale is easy. But in Step 4, there’s no Easy Digital Downloads option in the shopping carts list, so you should select “Developer Install” as below:

Then, just simply copy the following codes to the functions.php of your theme.

add_action( 'wp_footer', 'shareasale_pixel' );
function shareasale_pixel(){
/* Config */
$merchantID = 'Your ShareASale ID';
$currency = 'USD';
$sscid = ! empty( $_COOKIE['shareasaleSSCID'] ) ? $_COOKIE['shareasaleSSCID'] : '';
global $edd_receipt_args;
$payment   = get_post( $edd_receipt_args['id'] );
$order_id = edd_get_payment_transaction_id( $payment->ID );
$subtotal = edd_get_payment_subtotal( $payment->ID );
$amount = edd_get_payment_amount( $payment->ID );
echo '<img src="'.$order_id.'&amount='.$amount.'&currency='.$currency.'&merchantID='.$merchantID.'&transtype=sale&sscidmode=6&sscid='.$sscid.'" width="1" height="1">
<script defer async type="text/javascript" src=""></script>';
add_action( 'wp_head', 'shareasale_track' );
function shareasale_track(){
echo '<script>
var shareasaleSSCID=shareasaleGetParameterByName("sscid");function shareasaleSetCookie(e,a,r,s,t){if(e&&a){var o,n=s?"; path="+s:"",i=t?"; domain="+t:"",l="";r&&((o=new Date).setTime(o.getTime()+r),l="; expires="+o.toUTCString()),document.cookie=e+"="+a+l+n+i}}function shareasaleGetParameterByName(e,a){a||(a=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var r=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(a);return r?r[2]?decodeURIComponent(r[2].replace(/\+/g," ")):"":null}shareasaleSSCID&&shareasaleSetCookie("shareasaleSSCID",shareasaleSSCID,94670778e4,"/");

Please note, you should replace the following arguments:

  1. Change the $merchantID value.
  2. Change the currency, the default is USD.
  3. Change is_page(‘purchase-confirmation’) to the page id or slug of the “Purchase Confirmation” page on your website. For example, if this page slug is “success-page” on your website, you should write as is_page(‘success-page’).

Additionally, look at line 14:

<img src="'.$order_id.'&amount='.$amount.'&currency='.$currency.'&merchantID='.$merchantID.'&transtype=sale&sscidmode=6&sscid='.$sscid.'" width="1" height="1">

You can see “&amount=’.$amount.’& argument, by default, the amount value is after using the coupon code, if you want to track the subtotal which is before using the coupon code, just change it to “&amount=’.$subtotal.’&

That’s it! Now back to the ShareASale website, continue to the next step, testing the tracking code. Click the “Begin the Test” button, it will open your website in a new browser tab or window, now you need to make a purchase on your website.

Once you finished the purchase on your website, back to the ShareASale page, if you can see the correct order and commission information, it means done!

The rest of the setup steps are very easy to understand, you can do it by yourself.

If you are still looking for an Easy Digital Downloads theme, don’t forget to take a look at our Dew EDD Theme. Good luck with your sales!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.