Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

How to set up a Refer A Friend program

Hi there,

I want to set up a Refer A Friend program where each customer has a unique code they can share with their friends. It will give a one-time discount on a purchase by the friend. I will track the referrals and the customers earn product from our store.

What would be the best way to approach this?

An old thread suggests creating a stack of coupon codes and then assigning them to customers.

Is this still a good way to approach this? Foxycart's coupon features are much better than 6 years ago so it should be relatively easy to set it up so that each person can only use each code once but each code can be shared many times. It's just figuring out how to assign 1 unique code to each customer and then let them know, ideally in their receipt, what their code is.

I see in another thread, the suggestion to use the Customer ID as the referral code.

How would this be set up so that the Customer IDs are recognized as coupon codes?

  • fc_adamfc_adam FoxyCart Team

    That's for providing a detailed overview of what you're looking to set up. That's a good question.

    There are a few different ways you could approach this, depending on how automated you want the set up to be.

    As an example, utilising the customer ID could be a great way to approach it. It's already a unique identifier for each customer, makes it easy to connect it back to the customer on your side, and as it's already included on the receipt, is easy to display to customers. For displaying it to the customer, you would edit the receipt and email templates to add in some custom text, displaying their code (either as their straight customer ID, or perhaps with a prefix of some kind).

    The trickiest part would be in updating the coupons to include each new customer ID that needs to be added. You could handle this manually if you wanted, or you could also automate it with our API. Using our webhooks, you could trigger an endpoint on your side at the completion of each successful order. If it's a new customer, you could use the coupon resource in the API to find the coupon, and add the customer's ID as an additional code on the coupon. That would mean the coupon code was ready for the customer to pass on to others as soon as they completed their order. You could also create individual coupons for each customer too if you prefer - isolating each one to allow different discounts and track usage easier for each referral. It could make managing your coupons a bit cumbersome though, depending on how many customers would be added to this program.

    For the coupon - you could configure that to only allow a single use per code per customer in the usage settings. That would mean that a customer could only use a given referral discount once, restricted based on their email address entered.

    Could that approach work for your needs? Would you be comfortable working with the API to set up that kind of automation?

    Let us know if we can provide any further details, or if you have any questions!
  • Thanks Adam!

    It sounds like it could be not too complicated to set up - at least for the developer I'm working with. ;-)

    The other option I'm looking at is signing up with Referral Candy. According to, it is supposed to integrate with Foxycart though I can’t see any current discussion about it in this forum and Foxycart is not listed as a supported platform by Referral Candy. What do you think - would that be an easier way to get this set up? I'm not clear from their site how much work is involved.

    Referral Candy comes with other features which are attractive (e.g. fraud detection and it does the follow up with customers and makes it easy for them to share the codes).

    Thanks again, I appreciate your help!
  • fc_joshfc_josh FoxyCart Team
    Hi @Sparky.
    Referral Candy offers a great service and may be a quicker and easier approach since so much is already built and ready to go. Here's information on integrating Foxy and Referral Candy: If you run into any issues at all, please don't hesitate to reach out.

  • Thanks @fc_josh !
  • Hi there - I just sent this via your Contact form but really should have posted it here.

    I'm having trouble getting Referral Candy working with my store. It is connected by email so Referral Candy gets notified about every purchase.

    There have been a couple referred purchases but it is not being tracked. It needs some tracking code pasted into the "purchase completed page" which (I think) should be the Receipt page which is a subdomain. The only way I can figure to get it there is to add it to the header / footer (Add custom header / footer to your templates) but that is not working.

    Initially I tried putting it on the store's Thank You page but that did not work. And not everyone goes there after the Checkout / Receipt.

    Can you help? Here's the Referral Candy info on how to set things up:

  • fc_adamfc_adam FoxyCart Team

    Good question. Adding the code into the "Add custom header and footer code to your templates" configuration option will add the code to the receipt for you, but it will also output it for the cart and checkout if it's not otherwise configured to limit it to just the receipt. Perhaps having it on the other pages too was causing issues for the tracking?

    If you wanted to restrict it to just the receipt, you can wrap the custom code in Twig tags like this, and include it in the "footer" textarea, rather than the "header":
    {% if context == "receipt" %}

    {% endif %}
    That will only output anything in-between those two tags on the receipt. Potentially though you'll only want the code output on the first time the receipt is loaded (ie: when the customer first sees the receipt after a successful purchase), rather than every time and potentially track a customer just revisiting their receipt. To do that, you'd instead wrap your code in a slightly different Twig tag:
    {% if first_receipt_display %}

    {% endif %}
    Hopefully that helps get the tracking working. If you're still not seeing it after completing that - it may be worth touching base with the Referral Candy team, as they may have some insight into why it's not tracking when it's being output.
  • this worked - thank you @fc_adam !

    you guys rock - amazing support yet again :smiley:
Sign In or Register to comment.