When using the Formidable Form plugin in Wordpress, you will need to take some additional steps to connect it to Lead Gen & CRM.
Article Contents
Trial | ✓ | |
Essential | ✓ | |
Advanced | ✓ | |
Ultimate | ✓ |
Administrators | ✓ | |
Company Managers | ||
Marketing Managers | ||
Sales Managers | ||
Salespersons | ||
Jr. Salespersons |
Generating Formidable Forms
Non-developers can generate a Formidable Forms integration code with Lead Gen & CRM's Formidable Forms Integration Tool.
Modifying Code: Form ID Values
Due to the way the Formidable plugin handles submissions, you should not place native form code directly on the page. You still need to generate native form code, but you will need to add additional code and make some changes to your Wordpress functions.php file in order for it to work.
To modify Wordpress code, do the following:
- Open a new tab in your web browser.
- Log in to Wordpress in that browser tab.
- Locate your functions.php file.
- Add the following code snippet to the functions.php file:
add_action('frm_after_create_entry', 'submitSharpSpring', 30, 2); function submitSharpSpring($entry, $form_id){ // A block of code will be placed here for each connected form }
- Add the form's ID number, where XXXX is the form's ID number, in the $form_id line of the code:
if ($form_id == XXXX) {
- If necessary, add additional lines of $form_id code for each connected form.
You can track multiple Formidable forms on a page by placing your additional form code below the first form's code snippet within the same function. The supplied example code has multiple Formidable forms tracked on the same page.
Modifying Code: Post URL Values
Once the form_id
code has been added to the functions.php file, you will need to insert a post_url
code. The $post_url
value comes from your native form embed code. It is the BaseURI
value followed by the endpoint
value.
To add post_url
values, do the following:
- Insert a line in the functions.php file after the form_id codes.
Consider the following example code:
$post_url = 'https://app-3QEBQFRBMQ.marketingautomation.services/webforms/receivePostback/MxYwt7A0MDS3BAA/f91c3547-be72-4429-b964-54f12e24d76c/';
- Enter the $post_url value.
- Below the inserted $post_url value, insert the following:
$body = array(
- Insert one line for each field on the form within this section.
Consider the following example code:
'first_name' => $_POST['item_meta'][83], 'last_name' => $_POST['item_meta'][122], 'email' => $_POST['item_meta'][90],
- Repeat until every field you wish to capture has been included.
When inserting lines for fields, the label on the left can be any alphanumeric value as long as it is does not include ?, /, \, or ().
This will be used for mapping the data to Lead Gen & CRM. Giving your field a descriptive name will make mapping easier. The number in brackets at the right of each line is the field number within Formidable Forms.
Within Formidable Forms, checkbox groups will consider each checkbox a separate field. However, Lead Gen & CRM expects checkbox groups to be sent as a comma-separated list of values, which is the HTML standard for checkbox groups. If you have a checkbox group, its line should look slightly different.
In the following example, input 92 is a checkbox group. To have it work with a different field, replace the field’s ID number:
'Issues' => implode(',',$_POST['item_meta'][92]),
Modifying Code: Tracking Values
Once the form_id
and post_url
code have been added, you can add a tracking cookie to the form. This field does not show up when mapping the fields, and it must always have the name of ‘trackingid__sb’ with two underscores.
To add tracking, do the following:
- Insert a line after the post_url field mapping codes in the functions.php file.
- Enter the following tracking code:
'trackingid__sb' => $_COOKIE['__ss_tk']);
- Add the following code after the above tracking code:
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) ); - Insert an additional closing curly bracket
}
after the last form to close the entire function.
Consider the following example code:
);
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
Example Completed Code
The supplied example code is fully formed with a single form (Formidable Form 6) being captured, along with relevant notes.
add_action('frm_after_create_entry', 'submitSharpSpring', 30, 2);
function submitSharpSpring($entry, $form_id){
if ($form_id == 6) { // This will be the form number as defined in Formidable. This is an example of capturing Form 6.
// The below line is constructed using your native form code. The BaseURI value forms the first part of the URL, followed by the endpoint.
$post_url = 'https://app-3QEBQFRBMQ.marketingautomation.services/webforms/receivePostback/MzYwt7A0MDS3BAA/f91c3547-be72-4429-b964-54f12e24d76c/';
$body = array(
// There should be one line for each field on your form. The name on the left is how Lead Gen & CRM will receive it. The number on the right
// is the field number within Lead Gen & CRM.
'first_name' => $_POST['item_meta'][83],
'last_name' => $_POST['item_meta'][122],
'email' => $_POST['item_meta'][90],
// The line below for 'Issues' is an example of how a checkbox group would be added. Only use this method of the field is a checkbox group.
'Issues' => implode(',',$_POST['item_meta'][92]),
// This line must be present in addition to your fields in order to grab the cookie and establish tracking on the device.
'trackingid__sb' => $_COOKIE['__ss_tk']
);
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
}