Automatic AdWords Website Phone Conversion Script

The standard AdWords phone conversion script asks you to edit the HTML on every page. Here is a script that finds and wraps the numbers for you instead.

By Mark Koemans 2 min read

Flat lay of a white keyboard, two rose gold pens, reading glasses and a blank lined notepad on a white desk

This article is also available in German.Read the German version

When I started to implement the AdWords website phone conversion script for our clients I ran into several issues. And those exist because the original script requires the client to change the HTML code in several places on his website. Every phone number on each page of the entire website needs to be wrapped into a <span> tag with a specific ID. While on some websites this might be easy because only one or two templates need to be changed there are also websites where it becomes more difficult.

The difficulties I ran into

  • The website operator is slow to implement such changes
  • The number lives not only in templates but across many sub pages with no central reference, so good luck finding all of them on a big site
  • More than one AdWords account advertises distinct parts of a site built on the same code base, such as page-1.example.com and page-2.example.com

So I started to extend the original script with functionality that would simply read a configuration and change all phone numbers on the website dynamically without having to change the HTML code. The idea was to insert the script in the <head> section of every page of the entire website. Most websites allow this by editing one template and the job is done.

But I ran into one more issue. Changing the text on a website with JavaScript can render other scripts inoperable if not done right. But I figured it out!

The result is a script that can be inserted into the <head> section of a website. It doesn’t slow down the rendering of the page and it changes the phone numbers dynamically, everywhere.

I especially like about this solution that the script can be implemented with Google Tag Manager. It is deployed very fast and several scripts for different parts of a website can be used very easily.

Does this solution have any downsides?

And there is one bonus. The script works with clickable phone numbers too (those which are wrapped into an <a> tag).

Without further ado, go and grab the script in the following section.