> 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" %}
**Requirements to make Formsort work with GrowSurf**:

* Your flow must be embedded on your own webpage with Formsort's [embed code](https://docs.formsort.com/publishing-and-deployment/embedding) (you cannot use the stand-alone `https://xxxx.formsort.app` webpage).
* Your webpage's domain must be allowed to receive answers from Formsort. In Formsort Studio, open *Security*, then *Embedding domains*, and add it there.
  {% 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 Program Editor and navigate to the *Installation* tab.‌

**Step 2:** Continue through the installation steps until you reach the step that asks how GrowSurf will know a referred friend signed up.​

<figure><img src="https://2794996218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LeklWo0yn03AhWro2Ux%2Fuploads%2Fgit-blob-875caf830175ee4e001c09ae5704e63a3a264abe%2Fform-builder-prep-your-form-step.png?alt=media" alt=""><figcaption></figcaption></figure>

**Step 3:** Click the Formsort icon and follow the instructions GrowSurf shows (see image below).

<figure><img src="https://2794996218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LeklWo0yn03AhWro2Ux%2Fuploads%2FVYisix2R2uz6RRS9VsuR%2FScreen%20Shot%202026-10-09%20at%2010.00.05%20PM.jpg?alt=media&amp;token=2c7f3bf7-e87e-4d29-b4f0-7afa973ab378" alt=""><figcaption></figcaption></figure>

**Step 4:** Then finish the remaining installation steps.‌

## 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. Instead, when a respondent reaches the end of the flow, Formsort sends your page a `FlowFinalized` event with the collected answers. The GrowSurf code block listens for that event, reads the respondent's email address and name, and adds them to your program as a referred friend.

Formsort only includes the answers when your domain is allowed. In Formsort Studio, open *Security*, then *Embedding domains*, and add your website's domain:

<figure><img src="https://2794996218-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LeklWo0yn03AhWro2Ux%2Fuploads%2Fgit-blob-0b82fc36f34b96b29d13404904bfc728ea2e2d5d%2Fformsort-embedding-domains.png?alt=media" alt="Formsort Studio Security, Embedding domains, with a website domain added"><figcaption></figcaption></figure>

The code block works with the embed code Formsort Studio gives you, whether or not *Load immediately* is checked, and with Formsort's [web embed API](https://docs.formsort.com/publishing-and-deployment/embedding/web-embed-api). The code block only accepts the event from Formsort's own addresses (`formsort.app` or `formsort.com`). If you serve your flow from your own domain, change `FORMSORT_ORIGIN` in the code block to match that domain.

For each field, the handler uses the first matching answer key in this order:

* Email address: `email`, `email_address`, or `emailAddress`, otherwise the one answer that is itself an email address (if several answers are, nothing is sent)
* 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 no email address is found, nothing is sent, and no participant is added.

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

* While following the instructions GrowSurf shows, you may skip any steps that you have already completed in a 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.growsurf.com/integrations/formsort.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
