Dynamically Publish Tracking Phone Numbers With Cookies
Wednesday, April 30th, 2008This article explains how to publish a Mongoose Metrics tracking phone number on landing pages and websites where the tracking phone number is passed in the destination link of a paid search ad and set to cookie. This method is ideal for advertisers who want to drive traffic through ppc/paid search and have a measurement of which keywords in the paid search campaign resulted in offline phone call conversions.
Tracking Phone Number Publishing Example Scenario
- Searcher clicks on paid search ad.
- In the destination URL of the ad is the tracking phone number.
- When the searcher arrives at the landing page/website through the destination link, the tracking phone number is set to a cookie on the searcher’s computer.
- From the set cookie, the tracking number is published on the landing page and if needed throughout the entire website.
- Since the tracking number is set to a cookie on the searcher’s computer, should the searcher return to the website at a later date, the tracking number will re-appear.
- If the visitor does not arrive at the site through a paid search destination link that contains the tracking number, the website’s default phone number appears in its place.
- With all Mongoose Metrics tracking phone numbers, when the phone number is dialed, the phone call event will be injected into your analytics package of choice.
The above scenario demonstrates how paid search campaign managers can use Mongoose Metrics phone call tracking numbers in their campaigns and gain key insights into which keywords convert to offline phone calls.
Tracking Phone Number Implementation Instructions
This solution is entirely Javascript based and will work on any browser that is Javascript enabled and will accept cookies.
Step 1. This step has two parts. First, paste the below on-page js snippet of code on the landing page of your campaign. This should be the same page that your destination link containing your tracking phone number links to. This code will set the tracking number found in the URL to a cookie on searcher’s machine.
Second, you must paste the same code in place of any phone numbers on your site. Paste the code in the body of your webpage where-ever you wish for the phone number to appear. The js snippet will either publish the default phone number or the phone call tracking number depending on if the set cookie is found.
<script language="javascript" src="/MM_PhoneTracking.js"></script>
<script language="javascript" >
key = getVar("keyword");
tn = getVar("phone_number");
source = getVar("source");
content = getVar("content");
campaign = getVar("campaign");
if(tn!="")
{
setcookie(key,tn);
}
getcookie(); //call getcookie function to retrive the cookie
</script>
Step 2. Download the file MM_PhoneTracking.js by right clicking and saving this link.
Step. 3. On line 24 of MM_PhoneTracking.js you’ll need to replace the demo number with the default number of your website. The default number is the phone number you want dialed when the visitor did not arrive at your site through your campaign.
Step 4. Post MM_PhoneTracking.js to the root directory of your site. If you want to post the file elsewhere that’s fine but be sure to edit the on-page js snippet which references the path.
Step 5. That’s it! To set the tracking number to cookie you must arrive at any page that contains the on-page js snippet and also have the tracking number in the URL. The on-page snippet is used to both set the tracking number to cookie and/or display the tracking number so paste it on the entry page of your campaign and anywhere you want the phone number to appear.
The syntax of the url paramter is:
tracking_number=8001234567
An example link is:
http://www.mongoosemetrics.com/?tracking_number=8001234567
Additional Implementation Notes
Changing phone number format.
Both the default and tracking number must be stored and passed without formatting. You can change how the phone numbers will appear on the web page beginning on line 46 of the MM_PhoneTracking.js file.
Changing How Long The Cookie Is Stored
By default the cookie is set to save on the visitors machine indefinitely. If you need to change how long the cookie is kept before expiring you may do so on line 12 of MM_PhoneTracking.js
