Skip to main content

CallTrackingMetrics Integration

Learn how to track phone calls using the CallTrackingMetrics integration with Cometly.

Updated over a week ago

How to Set Up the CallTrackingMetrics Integration with Cometly

Learn how to integrate CallTrackingMetrics with Cometly to track phone calls as conversion events and pass your Cometly tracking token (comet_token) into your CallTrackingMetrics account.

Why This Matters

Integrating CallTrackingMetrics with Cometly lets you accurately attribute phone calls to your marketing campaigns. By sending the comet_token into CallTrackingMetrics, Cometly can match calls back to the ads and traffic sources that generated them.


Step 1: Prerequisites

Before starting, ensure:

  • You have admin rights in CallTrackingMetrics.

  • Your CallTrackingMetrics account is on a Marketing Pro plan or higher.


Step 2: Buy a Tracking Number

  1. Log in to your CallTrackingMetrics account.

  2. In the left-hand menu, click Numbers → Tracking Numbers.

  3. Click the Buy Numbers button.

  4. Select a number and click the + icon.

  5. Click Confirm & Purchase to complete your purchase.


Step 3: Create a Target Number

  1. Go to Numbers → Target Numbers.

  2. Click New Target Number.

  3. In the Target Number field, enter the phone number displayed on your landing page.

    • This number will be dynamically replaced by CallTrackingMetrics.

  4. Set Match Type to Phone Match.

  5. Click Save Changes.


Step 4: Create a Tracking Source

  1. Go to Tracking Sources.

  2. Click New Tracking Source.

  3. In the General section:

    • Enter a Tracking Source Name.

    • Toggle Onsite (dynamic) ON.

    • Click Save Changes.

  4. In the Matching Conditions section, go to the Landing URL tab.

    • Enter your landing page URL.

    • Click Save Changes.


Step 5: Install the Tracking Code

  1. Go to Numbers → Tracking Code.

  2. Copy your Tracking Code Script and paste it into the header section of your landing page.

  3. Scroll down to Advanced Options, then expand the Custom Tracking Code section.

  4. Paste the following script below your main tracking code

    1. Please ensure that you replace YOUR-COMETLY-PIXEL-HERE with your actual pixel (from this page):

(function(){
try {
var s = document.createElement('script');
s.src = 'YOUR-COMETLY-PIXEL-HERE';
s.async = true;
document.head.appendChild(s);
} catch(e) {}

})();

// 2) Read comet_token and push to CTM cvars

(function(){

try {
window.__ctm_cvars = window.__ctm_cvars || [];
function q(name){
try { return new URLSearchParams(location.search).get(name) || ''; } catch(e){ return ''; }
}
function ls(){
try { return localStorage.getItem('ctCartToken') || ''; } catch(e){ return ''; }
}
function sanitize(x){
return (x || '').toString().replace(/[^A-Za-z0-9._~\-]/g,'').slice(0,128);
}
var token =
(typeof window.cometToken === 'function' ? window.cometToken() : '') ||
q('comet_token') ||
ls();
token = sanitize(token);
if (token) window.__ctm_cvars.push({ _comet_token: token });
} catch(e) {}

})();

💡 Pro Tip:
This script ensures that each call session captures the visitor’s Cometly tracking token (comet_token) for accurate attribution inside Cometly.

Click Save Changes.


Step 6: Create a Custom Field for the Comet Token

  1. Go to Settings → Custom Fields.

  2. Under the Contact section, click Add Field.

  3. Enter the following details:

    • Field Name: Comet token

    • Type: Text

    • Save to: Activity

    • Check Log Visible

  4. Click Save Changes.


Step 7: Add an Update Field Action

  1. After saving the field, click Add Action.

  2. Select Update Field.

  3. In the fields list, select Comet token.

  4. Set Value to Session.

  5. Enter _comet_token as the value.

Click Save Changes.


Step 8: Create a Trigger

  1. Go to Flows → Triggers.

  2. Click New Trigger.

  3. In the General section:

    • Enter a name for the trigger.

    • Set Trigger to When a website session is associated to the activity record.

    • Toggle Trigger for all Activities ON.

    • Click Save Changes.

  4. In the Workflow section:

    • Click + Add Workflow.

    • Remove the default rule (trash icon).

    • Click Add Action and select Update Field.

    • Fill in the fields as in Step 7.

    • Click Save Changes.


Step 9: Activate CallTrackingMetrics in Cometly

  1. Log in to Cometly.

  2. Go to Integrations → Calls → CallTrackingMetrics.

  3. Click Activate CallTrackingMetrics.

After activation, you’ll see two available webhook event types:

  • Call Started

  • Call Answered

Copy the Callback URL for each event type you want to track.


Step 10: Create Webhooks in CallTrackingMetrics

  1. In CallTrackingMetrics, go to Settings → Webhooks.

  2. Click New Webhook.

  3. Enter a name for your webhook.

  4. Choose a trigger:

    • For Call Started, select When an activity is received [start].

    • For Call Answered, select When an agent answers a call queue [answered].

  5. In the Connection section:

    • Paste the Callback URL copied from Cometly.

    • Set Request Body Type to Log Data.

    • Click Save Changes.

Did this answer your question?