Installing the CTM Tracking Code on Your Site

To properly attribute calls and unlock the full power of your marketing data, you’ll need to add our Tracking Code to your website. This script is essential: it identifies where your visitors are coming from and dynamically updates the phone number displayed to match their source. This ensures accurate attribution, real-time insights, and complete visibility into campaign performance.

Important Setup Notes:

  • Already have another tracking code installed (This includes tracking codes from other CTM accounts)?
    Please remove it to avoid conflicts.  Our code must be the only call tracking script running on your site.
  • Avoid hardcoding tracking numbers.
    For dynamic number insertion (DNI) to function correctly, tracking numbers must not be hardcoded into your site.
  • Avoid placing numbers inside <object> tags or other embedded elements.
    Target numbers must appear in plain, visible HTML so our system can dynamically update them.

Installing your Tracking Code

  1. Navigate to NumbersTracking Code.
  2. Select your Setup Method
    • Standard Setup
      • Set up instructions for Website Builders
      • Instructions on how to add the tracking code directly to your website
        • Simply copy the tracking code and insert it between the <head> and </head> tags on every page of your website. You only have to add this code once to your website. The code will not need to be updated or reinstalled if you modify your account (allocate new tracking numbers, modify account settings, etc.).
      • Instructions to email you and your web developer, setup instructions
         
    • Developer Resources 
      • Understanding Tracking Code Variations: 
        • CallTrackingMetrics supports multiple Tracking Code domain variations. Depending on when your account was created or which setup method you choose, your Tracking Code may reference different domains or script URLs. Examples include:
          • https://xyz.tctm.co/t.js
          • https://cdn.tctm.co/t.js
          • Other CTM-provided tracking code domains shown on your Tracking Code page
        • These tracking code variations were introduced over time to support different infrastructure, performance, and deployment requirements. While the domains may differ, they are all designed to support Dynamic Number Insertion (DNI) and visitor tracking functionality.

        • Important:

          • You should use the Tracking Code provided directly within your CTM account whenever possible.
          • There is no need to update your tracking code solely because a newer domain variation exists.
          • If your website, hosting provider, content security policy (CSP), firewall, ad blocker, or CDN is preventing one tracking code domain from loading, you may be able to use one of the alternative tracking code domains available on your Tracking Code page.
          • Before changing domains, confirm that only one CTM Tracking Code is installed on your website to avoid conflicts.
    • For additional options and implementation details, see Alternative Tracking Code Domains below.

      • Alternative Tracking Code Domains
      • Handling Dynamic Content Changes
      • Optimizing Performance by Targeting Specific Elements
      • Self-Hosting with CDN
        • AWS CloudFront
        • Fastly CDN

Note: For steps on testing number swapping, see this article. 

AWS CloudFront

CloudFront allows you to load the tracking code through your domain, accelerating delivery and enabling whitelabel support. For detailed steps on setting this up, see this article

To configure CloudFront:

  • Set the origin to route traffic to: cdn.tctm.co
  • In the origin settings, enable:
    • "Use Origin Cache Headers"
    • "Allow All HTTP Methods"
    • "Cache Based on Selected Request Headers" set to All
  • Make sure your origin forwards the following two request headers: HeaderValue x-cdncloudfront x-act161383
    • x-cdn = cloudfront
    • x-act = 161383

Fastly CDN

Fastly supports multiple origin setups. To serve CTM assets:

Route the following URLs to tctm origin:

Path Origin
/t.js cdn.tctm.co
/f.js cdn.tctm.co
/p.js cdn.tctm.co
/x.json cdn.tctm.co

Request headers:

Header Value
x-cdn Fastly
x-act 161383

DNI can be blocked by slow scripts on your site, so we recommend placing our script before slower scripts to prevent visitors from seeing your original number being replaced as the page loads. Be advised that any additional dynamic number scripts running on the same site will interfere with the normal operation of the CTM dynamic number insertion. 

For Advanced Tracking Script Options, please refer to our API Integration guide.

Advanced Options

Expand the Advanced options to view the available optional features.

 

Cookie Settings

Another critical function of the CTM tracking code is that it remembers your visitors and continues to show them the tracking number that they saw when they first came to the site. This allows the software to attribute the callback to the original visit, so you know which ad was the one that first got their attention.

Determine how long a visitor's original marketing source (e.g., Google Ads, Facebook, email campaign) will be remembered for attribution purposes. The default is 30 days. Setting this value to 0 disables tracking and attribution via cookies.

Using third-party cookies can be beneficial if users visit a separate landing page before reaching your domain. If you prefer not to use cookies for your visitors, you can enable Last Touch for the tracking source. With this feature enabled, visitors will always be shown the tracking number that matches the most recent channel they used to get to your site.

Information Collected when the Tracking Code Fires

Parameter
Description
sid Session ID
score Session score
ip User IP address
browser Browser used
ua User agent string
loc Geolocation coordinates
mobile Is mobile device
times Session timestamps
referral_url Referrer URL
landing_url First landing URL
keywords Search terms/keywords
url_history Array of visited pages/queries
last_url Last URL visited
adblock Adblock detection
webproperty Google Analytics property ID
cookies List of cookies and their values
custom_variables Custom session variables
numbers Tracked phone numbers
google_explorer (null/not set in this sample)
paid Paid ad details (if present)
measurement_id Google Analytics Measurement ID
paid_ads_data (null/not set in this sample)
timezone User/session timezone

Visitor Call Analytics

Specify the minimum likelihood (1–99%) that a call is linked to a specific website visitor. If the match meets or exceeds this threshold, the visitor's tracking data will appear in the call log. Lower thresholds show more visitor data but may reduce accuracy. Higher thresholds increase accuracy but may show fewer records.

Block Tracking for Specific IP Addresses

Use this to exclude internal traffic from analytics—such as office locations, employee devices, or monitoring tools.

Custom Tracking Code

This is useful if you have graphical phone numbers or need to run custom logic using the CTMSourceEvent. 

Delaying the Tracking Code

To delay running the Tracking Code, expand Advanced Options and add the following script to the Custom Tracking Code section:

var ctmAlreadyRun = false;

window.CTMSourceEvent = function(event) {
if (ctmAlreadyRun) { return; }
if (event.state != 'before') { return; }
setTimeout(function() {
__ctm.main.runNow()
ctmAlreadyRun = true;
},1000);
// console.log(event);
}

You can also add the following if you need the Tracking Code to run after some interaction with the page, such as clicking a button to show a number:

__ctm.main.runNow(changedElement)

Changed element is the button click or object that needs to be interacted with to fire the code again.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.