Sometimes it can be useful to submit data directly to the endpoint of a Native Form. This allows a form to be submitted to SharpSpring without use of the Native Form embed code. Instead, a developer will need to create code to build a URL containing the form data, and post that URL to SharpSpring. This allows you to give your developer complete control over when form data is submitted to SharpSpring, and also allows you to further manipulate the data with your own code before posting it. For some forms, due to the way they are constructed or their method of submission, this method may be the only one available. Using this method, the data does not even need to come from an actual form, but can be pulled from any source your developer has access to.
A form’s endpoint will have the following structure:
With example data appended, it would look like this:
To find your form’s endpoint, create a Native Form in SharpSpring and view its embed code. I’ll use the below as an example:
Your form’s endpoint will be the URL on the line containing ‘baseURI’, plus the value following ‘endpoint’. It will then end with /jsonp/.
Given the above example:
The BaseURI is:
The Endpoint is:
Therefore, the endpoint URL is:
Below is an example of a submission to this endpoint with the first name of Jon, last name Walker, and email address Jon.Walker@sharpspring.com:
Note that the field names can be whatever you like, as long as they are unique and consistent on every submission. You will map these fields just as you’d map fields with any Native Form, so the incoming field names should be descriptive to make the mapping easier. Avoid using punctuation in the field names as well, as it could cause a submission error.
The above example will collect form data and create leads, but will not establish tracking on the lead as a form submission normally would. In order to establish tracking, you must gather the cookie and pass it in a field called trackingid__sb (note that it contains two underscores). This field will not appear on the field mapping page, and must always have this name.
You can retrieve the cookie called __ss_tk and pass that as the tracking ID value. If this is done, the form will establish tracking on the lead just as any native form would. The cookie can also be obtained using our Dynamic Web Content feature, but most often a developer will fetch the cookie with their own code.
Our tracking cookie should have a format similar to this:
So repeating the above example, with the addition of tracking the above cookie, it would look like this:
This can be accomplished in any language in which you can construct a URL and submit it as a GET request. In fact, the URL can be typed directly into the browser URL bar for testing, and the submission should come through.
Below you’ll find an example of doing this in PHP using cURL, which is the most common method, but the same logic would apply in any language: