Installing the JavaScript snippet

CallRail’s JavaScript snippet allows you to integrate call tracking on your website using dynamic number insertion (DNI). When customers navigate to your website from a marketing campaign, they’ll see the correct tracking number based on which marketing source they came from. 

The same JavaScript snippet powers both call and form tracking, so if you're using both products in CallRail, you don't have to install the same script more than once. After your company's snippet has been added to each page of your website, it gathers all the details of your customer's interactions on your website and relays their activity back to CallRail.

If you are using a WordPress or Wix website, please follow these instructions to install the WordPress plugin or the Wix plugin instead of using the JavaScript snippet. These will offer you the same functionality. 

How the JavaScript snippet works

Each company in your CallRail account has its own unique JavaScript snippet. The installation is just like installing Google Analytics — a single JavaScript snippet added to each page of your website before the </body> tag. This script tag works for both HTTP and HTTPS pages.

To use the dynamic number insertion feature, create tracking numbers within your CallRail account to track visitors from a specific source (like Google Ads.) When a visitor navigates to your website through one of the sources you’re tracking, CallRail’s JavaScript will detect the phone numbers on your web page and swap them with the correct tracking number. We’ll then store the visitor’s source in a cookie so they’ll continue to see the same tracking number each time they return to your website (unless your snippet is removed).

Getting started

There are a few important details you’ll need to know before you get started with dynamic number insertion:

  • Once you’ve installed the JavaScript snippet on your website, be sure to test your installation before your campaign begins.
  • Dynamic number insertion detects multiple number formats, including:
    111-222-3333, 111.222.3333, and (111) 222-3333.
  • Special steps are necessary to swap phone numbers in images. This help article explains more about image swapping.
  • Our snippet must be placed on the visitor's landing page, and each site page with a phone number or web form you would like to track.

Installing the JavaScript snippet on your website

Each company in your account has its own unique JavaScript code for dynamic number insertion. If you have multiple companies in your CallRail account, you’ll have a different code for each.

  1. Select the Integrations icon on the left navigation bar.
  2. Select JavaScript Snippet from the list of integrations.
  3. Choose the company where you’d like to set up this integration.
  4. Copy the JavaScript provided. It should look similar to this sample JavaScript code.
    screenshot_602.png
  5. Paste your script into each page of your website right before the </body> tag.

Auto-test your JavaScript installation

Once you've installed the JavaScript snippet on your web page, you can use the test dynamic number insertion feature to confirm that your snippet has been installed correctly and your tracking numbers are swapping on your site. Follow the steps in this article to test your JavaScript installation.

FAQs

How can I test that dynamic number insertion is working?

There are several ways to test that your DNI script is working properly. You can use our auto-test feature to see live swap examples of your tracking numbers swapped on your page or manually test dynamic number insertion.

I’m seeing the error: “The code snippet contains curly quotes or stylized text” when testing via the auto-test tool. What should I do?

Make sure your snippet does not have stylized characters. This can include curly quotes (‘…’ and “…”, elongated dashes (—), and em dashes (-).

If you’ve confirmed that your snippet does not have stylized text and you’re still receiving errors, we recommend manually testing your web page(s) instead.

Why isn’t my telephone number swapping?

Have you cleared your cookies or tried accessing the website in a private browsing session? The most important part of testing dynamic number insertion is to simulate the experience of a first-time visitor before testing. Otherwise, the swap code will detect you as a visitor from a previous session.

Troubleshoot common dynamic number insertion issues with this help article.

Can I use dynamic number insertion on my GoDaddy site?

No, we are not compatible with GoDaddy due to their use of iframes.

Can I use dynamic number insertion on my Wix site?

If you are on any of Wix's premium plans, you can install CallRail's JavaScript snippet in Google Tag Manager and add Google Tag Manager to your Wix site.

Use this article to learn how to add dynamic number insertion to Google Tag Manager.

Use these Wix instructions to learn how to add Google Tag Manager to your premium Wix site.

Do I need to remove the JavaScript after I deactivate call tracking?

If you don’t plan on creating new tracking numbers in the same company where your tracking number(s) has been deactivated, you can safely remove the CallRail JavaScript code. However, if you leave the swap script on your website, the numbers will no longer swap since those numbers have been deactivated.

Can I have a white-labeled version of my swap code?

Yes. When logged into CallRail via your white-label domain, use the instructions above to access a white-label version of your swap script.

I have multiple JavaScript codes for different locations of my business, can I install more than one JavaScript code on my website?

As a best practice, we recommend installing one JavaScript code on your website. While we can support installing up to three different CallRail JavaScript codes on a single website, but you may notice a reduction in number swapping speed. If you require multiple JavaScript codes installed on a single site, please reach out to our Support team for additional recommendations.

Was this article helpful?
5 out of 9 found this helpful

Articles in this section

See more
Ask the Community
Find best practices, post, and learn from CallRail users.
CallRail Support Hours
Weekdays 8:30am - 7:00pm EST
CallRail Classroom
Your go-to resource for brief, expert-led video tutorials.