Book&Learn’s API can be connected to a form in a WordPress website. It can be directly integrated in PHP, but if you use the Contact Form 7 plugin for your forms, it can can be easily connected without a code line. We recommend you instal the plugin first.
The integration works with a new form or with an existing one, you just need to consider the fields that need to be sent.
Step Before the Integration
Before you start the integration, B&L will provide you with some variables that you will use for the integration.
- widgetId: allows you to identify the formular that you are sending us through a token (HRfrM0q3HjsLGf24AL3nC7VX)
If you don’t have this information, please get in touch with us.
Download the Plugin
First step is to download the plugin Contact Form 7 to API. This plugin will allow to set the request to the API, once the form is sent.
Instal the Plugin
Go to the tab add plugins in your Wordpress website and upload the .zip file just downloaded.
Once the plugin is installed and active, go to the contact form section, and you will find a new tab where you can set up the call to the API.
In the configuration screen you will need to mark the field Send to api ? to activate the petitions’ request.
Set Up your Form
Here you will find an example of the form
The code that you need to include in the Form according to the integration example is:
<label> Your name (required)
[text* field-1-name] </label>
<label> Yopur last name (required)
[text* field-2-lastname] </label>
<label> Your email(required)
[email* field-3-email] </label>
<label> Your email
[tel* field-4-phone] </label>
<label> Choose the course you are interested on:
[select field-5-course "Language course|Language""Camps|SummerCamp" "Work abroad|WorkExperience" "Higher education|Degree"] </label>
<label> Where do you want to travel?:
[select field-6-destination "Australia|AU" "New Zealand|NZ" "EEUU|US" "Canada|CA" "United Kingdom|UK" "Ireland|IE" "Malta|MT" "Italy|IT" "Germany|DE" "France|FR" "Spain|ES"]</label>
<label> When do you plan to travel?:
<label> Where are you from?:
[select field-8-country "Mexico|MX" "Colombia|CO" "Brazil|BR" "Spain|ES"]</label>
<label> How do you know about us?:
[select field-9-referrer "Facebook" "Google" "Word of mouth" "Recommendation" "Our offices"]
[textarea field-10-comments] </label>
[acceptance acceptance-conditions optional] I agree to the Terms and Conditions [/acceptance] </label>
In some fields, such as country or destination, you should add the ISO Code so that it appears correctly. Example:
In case you want to add the courseType field, the available options are:
next to the option you can add the text you want to show on your form:
"language course" will be the words shown on the form but it also will send the required text for our API to work which is "Language"
You can create a very simple form by just using the following required fields:
Set Up the URL Base
To set up the URL you will need to have the following variables: host (Book&Learn server), agency id (agency name) and widgetId (an authentication token), this is the syntaxis:
These are the variables that will be integrated <> with the data provided.
Input Type: JSON
Set Up the JSON Template
The template can take the form values and convert them to the API required format. You can use the next code as a base and replace the values on quotes for the form’s names.
“firstName” are the API fields and the [field-1] are the fields added to the script in the lead form.
These are the fields can be added from your contact form to Book&Learn:
Please consider that some fields may require a special format that could not be compatible or require an extra development.
Once it is correctly set up, you will be able to register the leads on Book&Learn. If there is any error, the plugin allows you to visualise the data that was sent on the last request. This information will be used to find the error.
To visualise the error you need to click on the link + DEBUG LOG
It is important to check that:
- The URL is correct
- The JSON that is being sent doesn't have any sintaxis errors
- If the server’s error is 422, it means that a value sent is invalid. This may be because of the format or data integrity.