Basic Integration
Most affiliate systems will provide you with a tracking code that you can insert on a thank you page or confirmation page. Since this page is only displayed to the customer following a purchase, including the tracking code here means that you're only tracking commissions when a sale has occurred. In MemberMouse you can create confirmation pages that are specific to the product being purchased. This is where you would paste your tracking code.
Tracking codes will differ from system to system, but they will typically look something like this: <img border="0" src="http://www.youraffiliatesystem.com/sale.php? affiliate_id=[ MM_Order_Data name='affiliateId' ]& order_total=[ MM_Order_Data name='total' ]& order_number=[ MM_Order_Data name='id' ]& ip_address=[ MM_Order_Data name='ipAddress' ]" width="1" height="1">
All you need to do is use MemberMouse SmartTags™ to pass the appropriate data to the tracking code as demonstrated above. Read this article to get a complete list of order data available with the Order_Data SmartTag.
Note: When you use this approach you won't be able to take advantage of commission profiles or partner payouts. This is because you're manually tracking a commission on the confirmation page so you're bypassing the place where MemberMouse determines whether to track the commission based on commission profile and partner payout configurations.
Advanced Integration
You can create commission profiles and define partner payouts in MemberMouse that allow you to configure when you want to track commissions. In order to take advantage of these configurations, you'll need to let MemberMouse inform you when to make a call to your affiliate system to track a commission. You can accomplish this by listening for affiliate push notifications or creating functions that respond to affiliate WordPress hooks.
Affiliate Push Notifications
One way to ensure you're only tracking commissions in accordance with commission profiles and partner payout configurations is to put all of the code required to inform your affiliate system in scripts that are called by the MemberMouse push notification system. Read this article to learn how to call a custom script when affiliate events occur.
Affiliate WordPress Hooks
Another way to ensure that you're only tracking commissions in accordance with commission profiles and partner payout configurations is to put all of the code required to inform your affiliate system in functions that are tied to affiliate WordPress hooks. Below is an example of how you could attach a function to the mm_commission_initial hook. Read this article to learn more about using affiliate WordPress hooks.
add_action('mm_commission_initial', 'track_commission');
function track_commission($data)
{
$orderNumber = $data["order_number"];
$orderTotal = $data["order_total"];
$orderAffiliateId = $data["order_affiliate_id"];
$orderIPAddress = $data["order_ip_address"];
// access coupons associated with the order
$couponCode = "";
$coupons = json_decode(stripslashes($data["order_coupons"]));
foreach($coupons as $coupon)
{
$couponCode = $coupon->code;
break;
}
// generate URL to track commission
$url = "http://www.youraffiliatesystem.com/sale.php?";
$url .= "affiliate_id={$orderAffiliateId}&";
$url .= "order_total={$orderTotal}&";
$url .= "order_number={$orderNumber}&";
$url .= "coupon_code={$couponCode}&";
$url .= "ip_address={$orderIPAddress}";
// call URL using cURL
$request = curl_init($url);
curl_exec($request);
}