> For the complete documentation index, see [llms.txt](https://docs-vnext.kiflo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-vnext.kiflo.com/integrations/hubspot/get-leads-from-hubspot-forms.md).

# How to get leads from HubSpot Forms?

{% hint style="danger" %}
**Obsolete**

Kiflo now offers native integration with HubSpot Forms. There is no need for a third-party solution like Zapier or custom code to connect your contact form with Kiflo.

Documentation: [How to connect a HubSpot form to get leads from your website?](/integrations/hubspot/connect-hubspot-form-leads.md)
{% endhint %}

HubSpot Forms are an easy way to build forms and get leads from your landing pages. You can use your existing HubSpot Forms with Kiflo to track leads coming from partners.

Here is how it works:

* Install the **Kiflo JS snippet** on your website: to track visitors coming from referral links shared by partners. This will manage the tracking cookie automatically.
* Configure your HubSpot Form to get and save the **Tracking code**: this code is stored in the tracking cookie and must be sent along with the rest of the form
* Customize the JS code used to embed the form: in order to read the **Tracking code** from the existing cookie put by the **Kiflo JS snippet** and sent it to HubSpot
* Use the Tracking code to create a new lead in Kiflo

## Step 1: Install Kiflo tracking code

First things first, you need to install the Kiflo javascript snippet on your website. It is similar to Google Analytics snippet and will handle:

* Tracking cookies for visitors and leads
* Communication between your website and your Kiflo account

To install the Kiflo javascript snippet, please refer to this page: [https://docs.kiflo.com/article/34-get-started-with-kiflo-js](/developers/js-sdk/get-started.md)

## Step 2: Configure your HubSpot Form

Create or edit an existing form in HubSpot, the way you are used to it, then:

* Add a new field called: "**Kiflo Tracking Code**"
* Make this field **hidden**

{% hint style="info" %}
If you choose a different name than "Kiflo Tracking Code", please save the "Contact property name" (in red in the screenshot below) for later.
{% endhint %}

![](https://3041514930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKkJn82Qo5a0Y4fOsoQzo%2Fuploads%2Fgit-blob-d90f56fbc2a5355528ee198c9730038234893dc9%2F613b5f9612c07c18afdd2da9.png?alt=media)

At this point, you can save the Kiflo Tracking Code in HubSpot along with the other fields.

## Step 3: Customize the embed code

Copy the embed code from the HubSpot Form editor and add a new callback: "onFormSubmit" that will be executed just before the form is submitted to HubSpot.

This callback is in charge of reading the **Tracking code** from the tracking cookie (if there is one), and populate the hidden field created at step 2 with this value.

The code should look like

```
<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
	hbspt.forms.create({
		region: "na1",
		portalId: "1234567",
		formId: "72fadbf8-abaf-483e-ba65-c83755483421",
		onFormSubmit: function($form) {
			$form[0]["kiflo_tracking_code"].value = kiflo('getTrackingCode');
		}
	});
</script>
```

{% hint style="warning" %}
**Be careful!**

If you chose another name at step 2, please replace "kiflo\_tracking\_code" with the contact property name provided by HubSpot.
{% endhint %}

Find more information in the official HubSpot documentation: <https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options>

## Step 4: Send leads to Kiflo

Now you are ready to send leads to Kiflo! You have different options:

* Using Zapier
* Using API call

### Using Zapier

Create a new Zap, that can be triggered from different triggers from HubSpot, and add the **Create Lead** action from **Kiflo PRM**:

![](https://3041514930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKkJn82Qo5a0Y4fOsoQzo%2Fuploads%2Fgit-blob-e8831c6a22ccd7ff2aed5a3615af8940727fe1b8%2F613b64a512c07c18afdd2dc4.png?alt=media)

Map all fields coming from HubSpot, then at the very bottom of the setup action step, insert the **Tracking code:**

![](https://3041514930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKkJn82Qo5a0Y4fOsoQzo%2Fuploads%2Fgit-blob-8169e275db9766c42153ab0ade2f4f6ed479151e%2F613b65060754e74465f0f0a7.png?alt=media)

{% hint style="info" %}
You don't have to map the Partner field because Kiflo will use the Tracking code to associate the new lead with the source partner.
{% endhint %}

### Using API call

If you prefer to call the Rest API the create leads, please refer to this method: [https://docs-api.kiflo.com/#b285fe6c-af58-4d9e-a99c-7e87065da2b](https://docs-api.kiflo.com/#b285fe6c-af58-4d9e-a99c-7e87065da2b6)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs-vnext.kiflo.com/integrations/hubspot/get-leads-from-hubspot-forms.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
