Add a referral program to any website

If you can add a script tag to a page, you can run a referral program. No backend code is required.

Before you start

Create a free Monkey Referrals account and a referral program. The dashboard shows your exact script with your real business ID and embed code ID. The examples below use placeholders.

Add the widget script

Paste the script on the page that holds your form, just before the closing </body> tag.

<script
  src="https://cdn.monkeyreferrals.com/widget/v1/mr.js"
  data-business="YOUR_BUSINESS_ID"
  data-embed_code="YOUR_EMBED_CODE_ID"
></script>

The widget adds a Referral Code field to the first form it finds. It supports these options:

AttributeWhat it doesDefault
data-businessYour business ID (required)none
data-embed_codeYour embed code ID (required)none
data-formTarget a specific form on the pageFirst form found
data-validateCheck the code is valid before submitOff
data-insert-beforePlace the field before a specific elementBefore the submit button

Example with all options

<script
  src="https://cdn.monkeyreferrals.com/widget/v1/mr.js"
  data-business="YOUR_BUSINESS_ID"
  data-embed_code="YOUR_EMBED_CODE_ID"
  data-form="#signup-form"
  data-validate="1"
  data-insert-before="#submit-btn"
></script>

Add the confirmation snippet

Paste this on the thank-you or confirmation page shown after the form is submitted. It confirms the referral and credits the promoter.

<script>
  window.mr && window.mr('confirm');
</script>

If you cannot edit that page, skip this step and approve referrals manually from your dashboard.

Troubleshooting

  • The referral field does not appear. Make sure the script is on the same page as the form and check the browser console for errors. Add data-form with a selector for your form, for example data-form="#signup-form".
  • The form loads late. Some builders load forms dynamically. The widget waits for the form, but a data-form selector helps it find the right one.
  • Referrals stay pending. Add the confirmation snippet to your thank-you page, or approve them manually.

Questions? See the FAQ or contact us.

Ready to add your referral code field?

Free plan: one active program and unlimited successful referrals. Upgrade only if you need more.