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 you would like AffiliateWP to calculate a specific referral amount for each form submission, 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, you will need to add a Product field with a value of your choice, as well as a Total field for the final calculation.
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 Product field. The Total field will calculate the total price for the form, and subsequently, how much affiliate commission will be calculated.
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.
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 Price field for the Product section of the form. 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.
Final steps: Mapping the form with merge tags
If you have set up your form to calculate a specific referral rate based on Product and Total fields, 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 tag is Total.
- 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.