> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cometly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Jotform form tracking

> Set up Jotform form tracking in Cometly: pass the Comet Token into your embedded form so each submission is tied to the ad that produced it.

Jotform form tracking adds the Comet Token to every submission of a Jotform form embedded on your site. The Comet Token is the identifier the Cometly pixel (the tracking script you install on your site) gives each visitor, and it links a submission to that visitor's tracked session.

This matters because a Jotform form loads inside an iframe, so a submission does not carry the visitor's session on its own. Once the token travels with each submission, Cometly can attribute the events you send from Jotform to the correct source, and you can see which ad produced each lead.

## Before you start

> [!NOTE]
>
> This setup is for **Jotform forms embedded as an iframe**.

* The Cometly pixel is installed on the page that holds the embedded form. The code in step 2 reads the Comet Token from the pixel. See [Install the Cometly pixel](https://docs.cometly.com/getting-started/install-pixel.md).

## Step 1: Add a hidden field to your Jotform form

Add a new **Short Text** element to your form. For the **Field Label**, enter `comet_token`.

![Jotform Short Text Properties panel with the Field Label set to comet\_token](https://mintcdn.com/cometly/4NU5YV9iL1PADmGE/images/integrations/forms/jotform/01.webp?fit=max\&auto=format\&n=4NU5YV9iL1PADmGE\&q=85\&s=a5faa7d3688076dca46aab1c68ba475a)

With the `comet_token` Short Text field still selected, click **Advanced** and turn on **Hide field**.

![Jotform Short Text Properties on the Advanced tab with the Hide field toggle turned on](https://mintcdn.com/cometly/4NU5YV9iL1PADmGE/images/integrations/forms/jotform/02.webp?fit=max\&auto=format\&n=4NU5YV9iL1PADmGE\&q=85\&s=e6fc83ee8195d333d8123f75ccb71111)

## Step 2: Add custom code to your web page

On the page that holds the embedded Jotform iframe, add custom code that appends the Comet Token from the Cometly pixel to the iframe URL. This lets you retrieve the Comet Token from the submission and include it when you send the event to Cometly.

**1. Open the iframe embed code**

On the Jotform **Publish** page, click **Embed**, then **IFRAME**.

![Jotform Publish page with the Embed menu item and the IFRAME option highlighted](https://mintcdn.com/cometly/4NU5YV9iL1PADmGE/images/integrations/forms/jotform/03.webp?fit=max\&auto=format\&n=4NU5YV9iL1PADmGE\&q=85\&s=375091040ed52a2a43ba0a29b8fa9cb1)

**2. Copy the iframe ID**

In the IFRAME code, find `iframe id=` and copy the ID between the quotes. In the example below it is `JotFormIFrame-232904902981157`.

![Jotform IFRAME embed code with the iframe id attribute highlighted](https://mintcdn.com/cometly/4NU5YV9iL1PADmGE/images/integrations/forms/jotform/04.webp?fit=max\&auto=format\&n=4NU5YV9iL1PADmGE\&q=85\&s=163b5a4f06047a2a1aec225b0df2701a)

**3. Add the code to your page**

Add the code below to your page and replace `ADD.IFRAME.ID.HERE` with your iframe ID.

> [!WARNING]
>
> Only place this code on the web page where your iframe is embedded, and make sure you replace the iframe ID.

```html theme={null}
<script>
function getCometToken() {
    return cometToken();
}

document.addEventListener("DOMContentLoaded", function () {
    var iframe = document.getElementById("ADD.IFRAME.ID.HERE");

    var cometToken = getCometToken();

    if (cometToken) {
        var currentSrc = iframe.src;
        var newSrc = currentSrc + "&comet_token=" + encodeURIComponent(cometToken);
        iframe.src = newSrc;
    }
});
</script>
```

## Step 3: Send event data with a Cometly webhook or Zapier

You can send event data from Jotform to Cometly with a Cometly webhook or with Zapier. The Jotform integration guide covers both:

[Set up the Jotform integration](https://docs.cometly.com/integrations/platforms/jotform.md)

## Check it worked

Publish your page with the code added, then submit a test entry on the embedded form. The submission in Jotform now has a value in the `comet_token` field. If you send submissions with Zapier, the same value shows as **Answers Comet Token** in the test record.

## Frequently asked questions

### Why is the comet\_token field empty in my Jotform submissions?

The code only adds the token when it can read one from the Cometly pixel, so first check that the pixel is installed on the page that holds the form. Then check that you replaced `ADD.IFRAME.ID.HERE` with your own iframe ID, and that the hidden field's **Field Label** is exactly `comet_token`.

### Do I need the Cometly pixel to track Jotform forms?

Yes. The Comet Token comes from the Cometly pixel, so the pixel has to be installed on the page where the Jotform iframe is embedded. Without it, the code has no token to pass into the form.

### Does adding the hidden field send my Jotform submissions to Cometly?

No. The hidden field and the code only attach the Comet Token to each submission. To get the submission into Cometly as an event (an action Cometly tracks, such as a lead), you still send it with a Cometly webhook or Zapier, as in step 3.

## Next steps

* [Send Jotform submissions to Cometly with a webhook or Zapier](https://docs.cometly.com/integrations/platforms/jotform.md)
* [Create and map a Cometly webhook](https://docs.cometly.com/integrations/webhooks.md)
* [Connect Cometly to Zapier](https://docs.cometly.com/integrations/zapier.md)
* [Use the Events Log to check incoming events](https://docs.cometly.com/support/troubleshooting/general/event-log.md)
* [Form tracking for third-party embedded forms](https://docs.cometly.com/guides/form-tracking/third-party-forms.md)

Still have questions or need a hand? We're happy to help. Reach our team at [support@cometly.com](mailto:support@cometly.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.