Table of Contents


Integrating your Referral Rock program with Magento is simple. We'll go step-by-step through the setup needed to provide referrals with coupons for use in your Magento store and to track referral purchases.

This article references Referral Rock's Classic Landing page. If you are using our new Referral Page Web Page builder, please reference this article for instructions for how to build out a landing page.

Setting Up a Static Magento Coupon Code for Referrals

Step 1: Follow these instructions to create a coupon code in Magento. Magento gives you plenty of options for customizing coupon code behavior in your store, so spend some time setting up the coupon just the way you want! After you save the coupon, take note of the code that you created.

Step 2: Now that you have a coupon code that works in Magento, it's time to put it into Referral Rock. 

  1. In your program editor, navigate to the Referral Page or click here and choose Landing for Referral Capture. 
  2. In Page > Layout Options, click Yes under Display a code to referral, click Static Code, and then paste your Magento code into the box below. 

You'll want to spend some time customizing the landing page to make it perfect. The goal of the landing page is to give referrals a quick overview of your business, provide them with the static coupon code, and then pass them on to your store via the CTA button.

Referral Conversion Tracking in Magento

The next step in setting up Referral Rock to work with Magento is tracking conversions on your store. This will tell us which referral purchased from your store, the dollar value of their purchase, and who the member was that referred them so that you can reward that member. We'll be using a small snippet of custom PHP to track customer checkouts.

  1. Navigate to your Magento Source Code.
  2. Find the following file: [Magento root path]/app/design/frontend/base/default/template/checkout/success.phtml.
  3. Append your Magento Event Script (example below) anywhere towards the end of the file.
  4. Replace [YOUR REFERRAL ROCK URL] with your unique Referral Rock Postback URL. It can be found here.
  5. Save the file.
Your Postback URL should look like the following:

Magento Example Event Script

<?php    //Get the last order ID    $order_id = Mage::getSingleton('checkout/session')--->getLastOrderId();    //Get the order    $order = Mage::getModel('sales/order')->load($order_id);    //Get the grand total    $grand_total = round($order->getGrandTotal(), 2);    //Get the customer's email address    $email = $order->getCustomerEmail();    //Get the customer's name    $name = $order->getCustomerName();    //Construct the tracking pixel    $RRPixelString = '<img src="//[YOUR REFERRAL ROCK URL]?refid='.$order_id.'&name='.$name.'&email='.$email.'&amount='.$grand_total.'" height="1" width="1">';?><?php echo $RRPixelString ?>

Automating Referral Approval in Referral Rock

Back in Referral Rock, you'll want to ensure that referrals are automatically approved.

  1. In the Program Editor > Referral or click here > Conversion Settings > Settings
  2. Click the Yes box under Automatically approve referral? 
  3. When you create member rewards, ensure you are using the Approved Referral Status as the event trigger for the reward. 

How did we do?