> ## 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.

# Track CallRail calls

> Set up CallRail call tracking in Cometly so every phone call is recorded as an event and attributed to the ad or campaign that drove it.

CallRail call tracking in Cometly sends each call from your **CallRail** account to Cometly as an event (an action a person takes on the way to becoming a customer). This guide also attaches the [Comet Token](https://docs.cometly.com/concepts/comet-token.md), the identifier the Cometly pixel gives each visitor, to every call, so Cometly can attribute the call to the visit that led to it.

Tracking phone calls shows you which ads and campaigns generate revenue over the phone. Once CallRail is connected, you can trace an inbound call back to the original ad campaign, and calls from channels like Google and Meta are attributed in Cometly alongside your other conversions.

## Before you start

* You can edit the `<head>` of your website (for example with a header and footer scripts plugin).
* Your CallRail plan supports **Webhooks** and **Custom Cookie Capture**. CallRail offers these features as add-ons. They may be included in standard or premium packages, so verify that your plan has them.

## Set up CallRail tracking

**1. Add the Cometly pixel to the head of your website**

1. In Cometly, go to **Setup** and open the step **Install the Cometly pixel**. Under **Install the pixel**, click **Copy Code**.
2. Log in to your website platform (for example WordPress or Webflow).
3. Go to your global header and footer script section (often managed by a plugin such as *Header Footer Code Snippets*).
4. Paste the Cometly pixel in the `<head>`, and make sure it is installed on every page of your site.

For other ways to install it, see [Install the Cometly pixel](https://docs.cometly.com/getting-started/install-pixel.md).

![Cometly Setup page on the step Install the Cometly pixel, with marker 1 and an arrow on Setup in the sidebar and marker 2 with a box around the Copy Code button below the pixel snippet.](https://mintcdn.com/cometly/4NU5YV9iL1PADmGE/images/integrations/guides/callrail/01.webp?fit=max\&auto=format\&n=4NU5YV9iL1PADmGE\&q=85\&s=957121ac7918052f486201b40caee1dc)

**2. Add the cookie snippet after the Cometly pixel**

Place the following snippet *after* the Cometly pixel in the `<head>`:

```html theme={null}
<script>
 (function () {
  try {
   if (typeof cometToken === "function") {
    var token = cometToken();
    if (token) {
     var d = new Date();
     d.setTime(d.getTime() + 180*24*60*60*1000); // 180 days
     document.cookie = "comet_token=" + encodeURIComponent(token) + "; path=/; expires=" + d.toUTCString();
    }
   }
  } catch (e) { /* fail silently */ }
 })();
</script>
```

The snippet reads the visitor's Comet Token from the pixel and saves it in a cookie named `comet_token`, so CallRail can pick it up with the call data.

**3. Capture the Comet Token in CallRail**

1. In CallRail, go to **Integrations → Library → Custom Cookie Capture**.

   [Add Custom Cookie Capture in CallRail](https://www.loom.com/embed/d21eb6a0e6554509bc000c38aafc151d)

2. Create a new custom cookie and name it **comet\_token**.

This cookie captures the Comet Token when visitors land on your site.

**4. Send CallRail calls to Cometly with a webhook**

First create the event and its webhook URL in Cometly:

1. In Cometly, go to **Events Manager** and click **Create Event**.
2. Under **App / Integration**, select **Webhooks**.
3. Pick the event name, or choose **Create New Event** and give it a clear name such as "Phone Calls from CallRail". Click **Create**.
4. Under **Your webhook URL**, click **Copy**.

![Receive Data step for the event Phone Calls from CallRail, showing Your webhook URL with a box around the Copy button, and the Check for Data button below.](https://mintcdn.com/cometly/4NU5YV9iL1PADmGE/images/integrations/guides/callrail/03.webp?fit=max\&auto=format\&n=4NU5YV9iL1PADmGE\&q=85\&s=b6666520f4cd9ac33e0070576dfb4cb6)

Then add the URL in CallRail:

1. In CallRail, go to **Integrations → Library → Webhooks**.
2. Paste the Cometly webhook URL into the **Post-Call Webhook**, in the Webhook URL section.
3. Save the changes and publish the webhook in CallRail.

[Create Webhook in CallRail](https://www.loom.com/embed/e74f71a33f664b799d7488bebf6d4250)

> [!NOTE]
>
> **CallRail** is also in the **App / Integration** list. If you select it instead of **Webhooks**, you connect a CallRail account with an API key (in CallRail: **Settings > API > Manage API Credentials**), choose the **Post-Call** trigger and click **Continue**. Cometly then adds its webhook URL to your CallRail webhooks for you, so you skip the CallRail part of this step. The other steps stay the same.

**5. Map the Comet Token in Cometly**

1. In Cometly, open **Events Manager**.
2. Find the event you created in the previous step and click **Configure**.
3. Click **Check for Data**, select the most recent record and click **Continue With Selected Record**. If no record shows up yet, place a test call (see the next step) and check again.
4. On the mapping step, click **Add Field** and choose **Comet Token** under **Cometly Fields**.
5. Under **Data Fields**, search for your custom cookie field (`custom.comet_token` in the example below) and select it.
6. Map the remaining fields (the page requires **Email** and **Event Time**), then click **Save & Continue** and finish the setup.

![Mapping row with the Cometly field Comet Token mapped to the data field custom.comet\_token, with a sample token value and a delete icon.](https://mintcdn.com/cometly/4NU5YV9iL1PADmGE/images/integrations/guides/callrail/02.webp?fit=max\&auto=format\&n=4NU5YV9iL1PADmGE\&q=85\&s=d9ab715a15db9a4a55a447b13f31e39b)

Now, when a call comes in from a tracked source (such as Google Ads), Cometly attributes it to the ad or campaign that drove the call.

**6. Confirm your call tracking setup**

* Place a test call to a CallRail tracking number, after clicking a Google ad or visiting your landing page directly.
* In Cometly, open **Events Manager** and the **Events Log** tab to confirm the call event appears with the token attached.

## Check it worked

After your test call, the call event is listed in **Events Manager**, on the **Events Log** tab, with the Comet Token attached. From then on, a call from a tracked source (such as Google Ads) is attributed to the ad or campaign that drove it.

## Frequently asked questions

### Do I need a developer to connect CallRail to Cometly?

No. The CallRail setup does not use the Cometly API. You need to be able to paste the Cometly pixel and the cookie snippet into the `<head>` of your website, and to change settings in CallRail and Cometly.

### How long is the Comet Token kept for a visitor who calls later?

The cookie snippet on this page saves the Comet Token in the `comet_token` cookie for 180 days. The snippet only saves it when the Cometly pixel has loaded first, which is why it must be placed after the pixel.

### Which CallRail call events can Cometly receive?

This guide uses CallRail's **Post-Call Webhook**, which fires when a call has ended. If you connect a CallRail account by selecting **CallRail** under **App / Integration**, you can choose from four triggers: **Pre-Call**, **Call Routing Complete**, **Post-Call** and **Call Modified**.

## Next steps

* [Create and configure events](https://docs.cometly.com/getting-started/events.md)
* [Using the Events Log](https://docs.cometly.com/support/troubleshooting/general/event-log.md)
* [Set up call tracking with the Cometly API](https://docs.cometly.com/guides/events/call-tracking.md)
* [Connect CallTrackingMetrics](https://docs.cometly.com/integrations/platforms/calltrackingmetrics.md)
* [Comet Token](https://docs.cometly.com/concepts/comet-token.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.