The Gravity Forms (contact form plugin) can be integrated with the WP Affiliate Platform Plugin.
The following integration steps show how you can use the Gravity Forms plugin to capture leads in the WP Affiliate plugin.
What can you expect from this integration?
The following points show the usual flow of events that you can expect:
- You place a form created by Gravity Forms on your landing page.
- An affiliate sends a visitor to your landing page (The affiliate plugin detects this referral and tracks the click).
- The visitor decides to fill in the form on your landing page.
- After the Gravity form is submitted, the affiliate plugin detects that this user was sent by an affiliate.
- The affiliate plugin captures this lead in the lead capture table (the site admin can later check all the leads).
Gravity Forms Lead Capture Integration Steps
Step 1) The Gravity Forms lead capture form needs the following field in place:
- Email address – when you create the lead capture form using Gravity Forms, you will need to have an email address field in the form to collect the user’s email.
Step 2) Go to the advanced tab of the “Email Address Field” of your gravity form and specify the following value in the “parameter name” field:
wpap-lead-email
See the following screenshot for better understanding:
Step 3) Finally, use the standard gravity form’s shortcode to place the form on your landing page as you do for any other Gravity form. See example of a shortcode below:
[gravityform id=1 title=false description=false]
Now, when your visitors submit the contact form the lead will be captured in the WP Affiliate plugin.
You can view all the captured leads by going to the “Mange Leads” menu of the plugin’s admin dashboard.
Awesome thanks… that was my problem. You were right it was input_2. Everything seems to be working fine now.
Nope, just because its the fourth entry it doesn’t mean the name will be “input_4”. You need to edit your gravity form and you will be able to see the name of each feild from your Gravity forms editor. I had a quick look at your HTML code and it looks like the email input field name is “input_2”. You actually have no field with name “input_4” in that form.
I just double checked my function.php and I have it set as:
$buyer_email = $_POST[“input_4”];
Is that right? Because my email optin is the fourth one on the list as you can see here:
http://www.TelcoQuotes.com
Is there anything else it could be?
Thanks.
@Brandon, The “customer email” comes from the email address field of your Gravity forms that you created. It seems like you did not specify the correct input field name when you did the integration so it is not sending the customer email. To be more specify the following line of code (taken from the example code) needs to be changed to match with your gravity forms input field:
$buyer_email = $_POST["input_2"];
Did you change “input_2” field name to match with your gravity form’s email address field?
I was able to get this to work. But when I put in a lead as a test I go to my manage leads section and I can see the lead but it’s not showing the “customer email” which makes it hard to track. Why is it not showing the customers email. And how can I get that leads information? Where is this data stored, I would like to be able to see all of the information that was put into the lead, ie name, email, phone etc..
I’m setting this up to be a pay per lead program, do I need to award a commission before the affiliate can see that they generated a lead?
@brook, You don’t need to change the “10” and “2” values. 10 is the priority and 2 is for arguments.
NICE…thanks for that,
one last question….. what does the “10,2” mean from this line??
add_action(“gform_post_submission”, “gf_post_submission”, 10, 2);
dont have to change this do we?
Thanks again for the help.
You are opening and closing braces “{“, “}” are out of place. The else if condition is totally missing the braces too. Don’t bother creating “else if” conditions unless you are fluent in PHP. Only one form will be submitted by the user at a time. So you can keep on adding “if” condition for each of your form like the following structure:
if($form['id'] == 1)
{
//do stuff for the submission of form ID 1
}
if($form['id'] == 2)
{
//do stuff for the submission of form ID 2
}
if($form['id'] == 3)
{
//do stuff for the submission of form ID 3
}
add_action("gform_post_submission", "gf_post_submission", 10, 2);
OK I DONT GOT IT!!..lol…
can anyone help me with this….
im trying to add multiple forms, ive got to the bit (3rd post up from here)…. and im using dreamweaver cs5 to add the code to functions.php…..but every time i add the “else if statement” it’s showing errors….so i think im doing something wrong,,,,although i understand how php works, im not a programmer so bare with me…. basically im trying to add about 5 forms to this coding for affiliate platform to track…so would the code be like this…
if($form[‘id’] == 11)
{
//do stuff for the submission of form ID
// Build Lead Table Entries
$reference = $_POST[“input_9”]; //Unique ID
$clientdate = (date (“Y-m-d”));
$clienttime = (date (“H:i:s”));
$buyer_email = $_POST[“input_3”]; //Email
$ipaddress = $_POST[“input_8”]; // Client IP Address
global $wpdb;
$affiliates_leads_table_name = $wpdb->prefix . “affiliates_leads_tbl”;
$updatedb = “INSERT INTO $affiliates_leads_table_name (buyer_email,refid,reference,date,time,ipaddress) VALUES (‘$buyer_email’,’$aff_id’,’$reference’,’$clientdate’,’$clienttime’,’$ipaddress’)”;
$results = $wpdb->query($updatedb);
}
}
add_action(“gform_post_submission”, “gf_post_submission”, 10, 2);
}
else if($form[‘id’] == 9)
//do stuff for the submission of form ID
// Build Lead Table Entries
$reference = $_POST[“input_9”]; //Unique ID
$clientdate = (date (“Y-m-d”));
$clienttime = (date (“H:i:s”));
$buyer_email = $_POST[“input_3”]; //Email
$ipaddress = $_POST[“input_8”]; // Client IP Address
global $wpdb;
$affiliates_leads_table_name = $wpdb->prefix . “affiliates_leads_tbl”;
$updatedb = “INSERT INTO $affiliates_leads_table_name (buyer_email,refid,reference,date,time,ipaddress) VALUES (‘$buyer_email’,’$aff_id’,’$reference’,’$clientdate’,’$clienttime’,’$ipaddress’)”;
$results = $wpdb->query($updatedb);
add_action(“gform_post_submission”, “gf_post_submission”, 10, 2);
AND SO ON!! FOR THE NEXT FORM??
Please help…!! sorry for the long post but it’s only way i could explain it.
Cheers in advance
This is the key line that checks if a submission for a particular form happened otherwise it just returns and doesn’t do anything:
if($form['id'] != 12) return $form;
You can modify this to suit your needs like the following:
// Only Execute For Form 12 and 13 (the two lead capture forms)
if($form['id'] != 12 && $form['id'] != 13) return $form;
Then you can add more conditions down below to handle different forms differently if they have different set of fields. For example:
if($form['id'] == 12)
{
//do stuff for the submission of form ID 12
}
else if($form['id'] == 13)
{
//do stuff for the submission of form ID 13
}
I hope that clears it up.
Thanks for your response. I did read step 2 again. I understand the purpose of the unique_id field, but I have two forms. In step 3 you have us replacing the form ID. What happens when you have two different form IDs?
The affiliate plugin doesn’t require the name of anyone to award a commission. Why are we talking about the name field for the affiliate integration purpose?
“What happens when you have more than one lead capture form?” – Please fully read step 2 again (specially what the purpose of the “unique_id” field is and it should answer your question).
One more question… What happens when you have more than one lead capture form that you want to track? I just added a send copy of the code to the functions.php file and it broke the site again. How do I add a second lead capture form? Thanks
I figured out why the site was breaking. But I’m still wondering about the name field. Thanks
I understand step 1 and step 2. But when I put the code in step 3 in the functions.php file of my theme, it breaks the entire site. The pages won’t load at all. Is there a specific place within that functions.php file the code has to go? I’m changing the form ID # and the field numbers. ??? I also don’t see in your code above where the Name field is being captured. Are we supposed to add:
$name = $_POST[“input_1”]; //Name
to the code? Is $name the correct field name being used by the system? Your comments would be much appreciated. Thansk
Thanks very much for such a detailed breakdown. It really helped and everything is working great.
Thanks again!!
David
Hi David, I will try to address your confusion one by one. Just remember for your first test do not worry about getting it perfect. You will understand more as you get the integration and do a few tests.
Step 1) In the advanced tab of the hidden field just check the “Allow field to be populated dynamically” checkbox and type in “unique_id” in the parameter field.
Step 2) After you create a form (contact form) you need to place this form on a WordPress post or page so visitors can actually interact with the form. You place a form by using a shortcode like the following:
[gravityform id=12 title=false description=false field_values=’unique_id=1′]
You will need to change “id=12” to match with the ID of the form you just created. Every form you create will have a ID so you can place it on a post or page.
Step 3) When you created your form you probably placed a field for name, email, ipaddress etc. The way you can get their values is by specifying the input number. So for example if you created a form with the following 3 fields:
Name:
Email:
IP Address:
Unique ID:
Then the name would be “input_1”, email would be “input_2”, IP Address would be “input_3” and so on.
The Gravity forms guys will be able to explain more on this.
Let me know if the above explanation helps.
Thanks for putting these instructions up.
Although I understand what is generally needed, I am lost on a few points:
By the way, I’m using caps for clarity. I’m not shouting. :o)
STEP 1)
* e-mail address for the lead ~ NO PROBLEM
* hidden field to capture client IP (default value) ~ NO PROBLEM
* hidden field to capture unique id capable of being dynamically populated (I called mine unique_id) ~ THE HIDDEN FIELD HAS AN ADVANCED TAB WHICH DISPLAYS:
A section: “Default Value” (dropdown) with “Insert Variable” as the default which has a blank field by default under it. WHICH VALUE IS SELECTED WHAT GOES IN THE FIELD?
A section: “Allow field to be populated dynamically” (checkbox) and when checked, which is what we want, the following appears:
A section: “Parameter Name:” with a blank field. WHAT GOES IN THIS FIELD?
STEP 2)
Shortcut to invoke form and pass unique id (in case you want to call form from multiple places on your website)
[gravityform id=12 title=false description=false field_values=’unique_id=1′]
I’M AFRAID I DON’T UNDERSTAND THIS AT ALL. WHAT DO I NEED TO CREATE/EDIT/ADD AND WHERE?
STEP 3)
Following code to go into “functions.php” file of your theme (NO PROBLEM) – replace form id with your own form reference number (I ASSUME THIS IS JUST THE FORM ID AND NOT SOME DIFFERENT REFERENCE NUMBER FOUND OR CREATED ELSEWHERE) and replace the field numbers for the three $_POST’s (WHAT ARE THEY REPLACED WITH?).
I would be really grateful for any advice.
Thanks,
David