> For the complete documentation index, see [llms.txt](https://docs.growsurf.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.growsurf.com/integrations/formsort.md).

# Formsort

Add referral tracking to your Formsort flow to automatically recognize new leads that come through referrals.

{% hint style="info" %}
**Please note the following requirements to make Formsort work with GrowSurf**:

* Your flow must be embedded on your own webpage with version 2 or newer of Formsort's [web embed](https://docs.formsort.com/publishing-and-deployment/embedding/web-embed-api) (you cannot use the stand-alone `https://xxxx.formsort.app` webpage). Version 1 does not hand the answers to your page.
* Your webpage's domain must be allowed to receive answers from Formsort. If the email address never comes through, ask Formsort support to add your domain.
  {% endhint %}

## Prep Your Flow <a href="#prep-your-flow" id="prep-your-flow"></a>

If you have an embedded Formsort flow on your website that you want to add referral tracking to, follow these instructions:‌

**Step 1:** Open the GrowSurf campaign editor and navigate to the *Installation* tab.‌

**Step 2:** Continue through the installation steps until you reach the referral tracking method section.​‌

**Step 3:** Click the Formsort icon and follow your campaign-specific instructions. You will paste one HTML block onto the webpage that hosts your flow, then add a single line to your own Formsort embed code so GrowSurf is told when someone finishes the flow.‌

**Step 4:** Once your Formsort flow has been prepped, continue on with the rest of the GrowSurf installation process.‌

## How It Works <a href="#how-it-works" id="how-it-works"></a>

A Formsort flow runs in a cross-origin iframe, so its answers never reach your page's HTML. Formsort's web embed hands them to your page instead: when a respondent reaches the end of the flow, Formsort fires the `FlowFinalized` event with the collected answers. The GrowSurf code block adds a handler for that event, reads the respondent's email address and name, and adds them to your campaign as a referred friend.

The handler reads these answer keys, in order, and uses the first one it finds:

* Email address: `email`
* First name: `first_name`, `firstName`, or the first word of `full_name` / `fullName` / `name`
* Last name: `last_name`, `lastName`, or the second word of `full_name` / `fullName` / `name`

An answer that is not text — a multi-select, a file — is skipped rather than stored as someone's name. If your flow stores the email address under a different key, rename it in Formsort or edit the `email` line in the code block to match.

## Additional Tips <a href="#additional-tips" id="additional-tips"></a>

* While following your campaign-specific Formsort instructions in the GrowSurf campaign editor, you may skip any steps that you have already completed from previous setup in Formsort.
* If you run into issues or have any questions, please reach out to [GrowSurf support](https://support.growsurf.com/) for assistance.


---

# 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.growsurf.com/integrations/formsort.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.
