Overview AdWords call tracking will help you better understand the value of your campaigns by measuring the phone calls AdWords ads on Google.com generate for your business. This document is intended for webmasters who wish to install the AdWords call tracking code snippet on their site.
When you use website call tracking, you’ll place a small snippet of JavaScript code on any pages on your site where you’d like to display a phone number.
Google will then dynamically show unique phone numbers to visitors who’ve come to your site through your AdWords ads, and you’ll receive reports that show you the number of calls driven by each campaign you’ve chosen to track. All other visitors will see a default phone number that you place in the code snippet.
To get started with website call tracking, please follow the instructions below.
Step 1: Get a conversion tracking ID number AdWords call tracking uses a unique AdWords conversion tracking ID to match the calls generated by your campaigns to your account.
If you already have conversion tracking enabled for the AdWords account you’re using for call tracking:
Visithttps://adwords.google.com/select/ConversionTrackingHome *. (You can also reach this page by clicking 'Conversions' at the top of your account's Reporting_tab.)__Click_on_any_conversion_action_listed_on_the_Conversions'>Reporting tab.)
Click on any conversion action listed on the Conversions tab on your conversion tracking homepage.
Click on the Code tab, and scroll down to the snippet of conversion tracking code.
Find the number after “var google_conversion id”. It should look like this:
If you don’t already have conversion tracking enabled for the AdWords account you’d like to use for call tracking, you’ll need to generate a “fake” conversion tracking code snippet to obtain this ID number.
Visithttps://adwords.google.com/select/ConversionTrackingHome *. (You can also reach this page by clicking 'Conversions' at the top of your account's Reporting tab.)
Click 'New conversion' from the Conversions tab.
Name the conversion and select a category. If you’re not planning to install AdWords conversion tracking, you can use the name “Call Tracking” and select the category “Other.” Click “Save and continue.”
On the Code tab, you can keep the default settings and click “Save and get code.”
Find the number after “var google_conversion id” in your conversion tracking code. This is your conversion tracking ID.
Step 2: Install a number formatting script Next you’ll need to install a number formatting script in your site’s directory. This script lets you change the formatting of your phone number if you so choose (giving you the ability to display your phone number in formats such as 1.800.555.5555 or 1-(800)-555-5555 instead of the default format 1-800-555-5555). Even if you do not wish to change the formatting of your phone number, installation of the script is mandatory, as AdWords call tracking will not work on your website without it. The script should be saved in your site’s directory as a separate file: formatnumber.js Here’s the code you’ll need to save: function FormatPhoneNumber(number_string, format_string) {
num_of_x = 0;
for (i = 0; i < format_string.length; i++) {
if (format_string.charAt(i) == 'x') {
num_of_x++;
}
}
if (number_string.length != num_of_x) {
return number_string;
}
else {
formatted_string = "";
pos = 0;
for (i = 0; i < format_string.length; i++) {
if (format_string.charAt(i) == 'x') {
formatted_string += number_string.charAt(pos);
pos++;
}
else {
formatted_string += format_string.charAt(i);
}
}
return formatted_string;
}
}
Please save the above file as formatnumber.js in the directory of your choice. After the number formatting script has been installed, you’ll be ready to create your call tracking code snippets.
Step 3: Create your general call tracking code snippet There are two types of call tracking code snippets you’ll need to install on your website. First, there’s a general call tracking snippet: this snippet is used to request a unique call tracking phone number from Google, and you’ll place it at the beginning of the body of your webpage (it won’t be visible to your visitors). The second snippet takes the phone number requested by the general call tracking snippet and dynamically displays it on your webpage.
To create your general call tracking snippet, you’ll need to customize it by inserting three elements unique to your business:
Your AdWords conversion tracking ID (see step 1 above)
The path to the number formatting script you’ve saved to your directory in step 2
The default phone number you’d like to display
The default phone number you insert should be the phone number you normally use for your business, and not a number provided through AdWords call tracking. Google will replace your default number with an AdWords call tracking number whenever a visitor comes to your site through your AdWords campaign.
Be sure to enter this number as an integer, without dashes or spaces. For example, if your phone number is 1-800-555-5555, you’ll enter it in the code snippet like this: 18005555555.
Here’s the general call tracking snippet before you customize it:
var phone_number = "default phone number as a number without dashes or spaces”;
function GetPhoneNumber() {
return phone_number;
}
Now, let’s say your conversion ID is 1234567890, your number formatting script is in the directory http://example.com/codes/javascript, and your default phone number is 1-800-555-5555. Here’s what the general call tracking snippet will look like when correctly customized:
var phone_number = "18005555555”;
function GetPhoneNumber() {
return phone_number;
}
Now that you’ve created your general call tracking code snippet, you’re ready to create the snippet that displays your phone number.
Step 4: Create a snippet to display your phone number Now that you’ve created your general call tracking code snippet, you’ll need to create the snippet of code that displays your phone number. You’ll insert this snippet wherever you wish to display your call tracking phone number on your webpage. To customize this snippet, you’ll need to format the placeholder number (x-xxx-xxx-xxxx) to reflect how you want your phone numbers to appear, and insert your default phone number as a formatted string (i.e. formatted to match the placeholder number) into the code below: default phone number as a formatted string For example, if you’d like to include both dashes and parentheses in your number as it’s displayed, you could customize the code snippet as follows: 1-(800)-555-5555 Please note that the snippet above does not customize the color, font or size of a phone number as it’s displayed on your page. To change these elements, you’ll need to customize your HTML as usual. If you choose not to make any changes to the number formatting, your phone numbers will be separated by dashes, as in 1-800-555-5555.
Now that you’ve entered the following information, you’re ready to install the AdWords call tracking code on your site!
Step 5: Install the call tracking code on your website First, identify the pages where you’d like to display your AdWords call tracking numbers. As a best practice, you should consider putting AdWords call tracking code in every location where you display a phone number on your website so that your visitors aren’t confused by seeing different numbers on different pages. Once you’ve identified the pages you’d like to install AdWords call tracking on, you’ll add the two call tracking code snippets you created in steps 3 and 4 to the HTML of every page. Here’s how you’ll install AdWords call tracking code on a single webpage:
Add the general call tracking code snippet at the beginning of the body of the page (not the header).
Example snippet at the beginning of the page:
var phone_number = "18005555555";
function GetPhoneNumber() {
return phone_number;
}
Add the second code snippet to the locations on your webpage where you wish to display a phone number.
Example snippet at the location of a phone number:
1-(800)-555-5555 To avoid confusing customers with multiple, conflicting phone numbers, remember to place this code snippet everywhere on the page that your business phone number previously appeared.
Finally, if you wish to change the color, font, or size of the phone number you display, you can customize the HTML around this code snippet as usual.
Repeat this process on any webpage where you’d like to use AdWords call tracking. After you save your changes to these pages and push them live, you’re done! Now you’re ready to start measuring the number of phone calls your AdWords ads generate for your business.
Here’s a quick summary of the entire process: Obtain your conversion tracking ID number
If you already have AdWords conversion tracking enabled, access your code snippet to find your conversion tracking ID.
If you don’t already have AdWords conversion tracking enabled, generate a “fake” code snippet by signing up for conversion tracking in your account (AdWords conversion tracking code doesn’t need to be installed.
Install a number formatting script
Save the number formatting script we’ve provided as formatnumber.js in the directory of your choice.
Customize the snippet by adding your AdWords conversion tracking ID, the path to the number formatting script you installed in step 2, and a default phone number.
Create a snippet to display your phone number
Customize the placeholder number (x-xxx-xxx-xxxx) in the code snippet
Insert your default phone number into the code snippet as a formatted string
Install the call tracking code on your website
Identify the webpages where you’d like to use AdWords call tracking
Add the second code snippet wherever you wish to display a phone number
Customize the HTML as necessary to change color, font, and size of the phone number
Repeat this process on every page where you’re installing AdWords call tracking
Questions? If you have any questions about setting up AdWords call tracking on your website, please contact your Google client services team. They’ll work closely with the AdWords call tracking team to troubleshoot any issues you may encounter.