Ninja Forms 3.0 or higher
Ninja Forms 3.0 and higher is supported.
- Ensure AffiliateWP version 1.9+ is installed and activated.
- Ensure Ninja Forms version 3.0+ is installed and activated.
- To enable integration with Ninja Forms, go to Affiliates → Settings → Integrations and check the box next to Ninja Forms. Click Save Changes In the WordPress admin menu, go to Forms and click the Add New button.
- Click on the “Just click here and select the fields you want.” link to start building your form. Add at least a couple of fields (for example, First Name and Email).
- You will also be required to add a Submit button.
- To enable referrals to be generated for this form, go to the Emails & Actions tab. Click the Plus (+) icon in the bottom right corner of the page.
- Click the Add Referral option under the Installed section. This will add a new Action called "Add Referral" to the form. New "Add Referral" action added:
- When the Add Referral action has been added, your form will now generate $0.00 referrals for affiliates who refer form submissions. If this is OK for your setup, you are finished!
- If you would like AffiliateWP to calculate a specific referral amount for each form submission, or set a specific referral Description or Referral Type (Sale, Opt-in, or Lead), click on the cog icon next to Add Referral to edit the action. You'll see some new options appear on the right-hand side of the page.
- To calculate a specific referral amount for each submission (using a referral rate type of percentage), you will need to add optional fields to store values such as quantity and pricing if you'd like the user to select/set these values before submitting the form. You can name these fields whatever you like.
- To perform a calculation, Use the Advanced -
Calculationsaction to perform any multiplication, addition, etc. to come up with a total. Helpful video tutorial on how to use the Calculations feature in Ninja Forms: https://ninjaforms.com/docs/calculations/.
AffiliateWP will use the global Referral Rate and Referral Rate Type (as set in Affiliates → Settings → General) to calculate an affiliate commission based on the amount you enter in the TOTAL FIELD above.
Example of setting a Flat Rate referral rate: If Ninja Forms is your only integration with AffiliateWP and you wish to generate a $2.00 affiliate commission for a form submission, you could enter a Flat Rate of “2" in AffiliateWP’s General settings. Now, when an affiliate refers a visitor, and the visitor completes and submits this form, a commission of $2.00 will be generated for the affiliate and there isn't a need for setting a total amount.
Example of setting a Percentage referral rate: If you wish to use a Percentage referral rate type (e.g. you have multiple integrations and/or forms, or you would prefer to work with percentages), and you wish to generate a $5.00 affiliate commission on every submission of this particular form, you could set a global Referral Rate of 20% in AffiliateWP's General settings, and enter “25.00" in the field you are using as your TOTAL FIELD assignment you'll set below. When an affiliate successfully refers a visitor, and the visitor completes and submits this form, a commission of $5.00 will be generated for the affiliate.
NOTE: As of Ninja Forms version 3.4.6, the pre-defined Product and Total fields are no longer available. That said, you can use any field you create to store this information if desired, and then use the Calculation action to determine a final total to assign in the TOTAL FIELD on the Add Referral action. That total will be used in the referral amount calculation as before.
Otherwise, you can place a single numeric value in a field of your choice to be used for the final referral calculation in the next
Final steps: Mapping the form with merge tags
If you have set up your form to calculate a specific referral rate based on final total amount field, follow the steps below.
- Click on the click on the cog icon next to Add Referral to edit the action. You'll see some new options appear on the right-hand side of the page.
- In the Total field, click on the menu icon. Select the corresponding merge tag from your form. As per the below example, the merge field tag is Total, but the field can be named whatever you like.
- For any other fields in your form, click on the menu icon. Select the corresponding merge tag from your form. As per the below example, we've merged the email field in the form with the Email merge tag. Repeat this step as necessary to map your form.
- In the Description field, enter some text that clearly describes where the referral came from, such as “My Contact Form” or “My First Product”, etc.
- Click the Done button.
- Click the Publish button.
- If you haven’t already given your form a title, you'll be prompted to do so. Give your form a title and click Publish again.
Older versions of Ninja Forms
From version 1.7 onwards, you can now enable and disable referrals on any Ninja Form. Once the integration has been enabled:
- Go to the Settings tab of your form
- Open the Restrictions section
- Enable the Allow Referrals checkbox
- Click Save
Once enabled, AffiliateWP will automatically generate a referral each time the customer is referred by an affiliate and submits a form.
In Affiliates → Referrals, the Reference;column refers to the entry ID in Ninja Forms:
Clicking on the Reference column will take you directly to the entry details page in Ninja Forms.
That's it, you're done!
The old, old method
Note: Prior to version 1.6, Ninja Forms was only minimally supported. The old integration method is described below for reference or if you need to use it for any reason. If you use the method below, leave the Ninja Forms box unchecked in Affiliates → Settings → Integrations.
This document will walk you through how to setup simple referral tracking with Ninja Forms. It uses the same function that the [affiliate_conversion_script] shortcode uses and demonstrates how you can pass dynamic values into the function.
Most of the code shown below can be used to help you set up dynamic values for any other form plugin or system that you are using.
First, set up your Ninja Form with the fields you require. The total field is optional and if you choose not to have it, the referrals will simply be created with a zero value.
If you are wanting the amount to be calculated in the referral, take note of the Field ID for your total field:
And this is what the form looks like on the front-end:
Second, set up the form to redirect to another page upon submission. You can configure this option under the Notifications tab. This will be the page that users land on after submitting the form.
Third, copy and paste the following code (mind the opening PHP tags) into your child theme's functions.php or custom plugin. If you're using a total field, replace the $total_field_id variable below with the Field ID of your total field (shown in the second image above).
That's it! When a referral link is used and the customer fills out your Ninja form, a new referral will be created.