AdWords
3.9K members online now
3.9K members online now
Use AdWords conversion tracking and reporting to measure your results. Have a question about Google Analytics? Post it here, on the Google Analytics Community!
Guide Me
star_border
Reply

What is wrong with my Google Website Call Tracking javascript code?

[ Edited ]
Follower ✭ ✭ ✭
# 1
Follower ✭ ✭ ✭

[rant] It's amazing how little Google customer service rep understands html/javascript considering that they work for google [/rant]

 

I have few phone numbers I want to track via Google website call tracking (via Google call forwarding).

 

Here are three phone numbers that I want google to dynamically change:

 

 

<aside id="phone" class="one_third last">Call us! <a href="tel:8885551212" title="Call us!">8885551212</a></aside>

 

<a href="tel:8885551212" class="button_buy_big gradient action_button_1">Call for Free Estimate</a>

 

 

I have a javscript code that does this:

 

[ in header ] 

 

<script type="text/javascript">
var google_conversion_tracking_callback = function(formatted_number, mobile_number) {

jQuery("a.button_buy_big").attr("href", mobile_number);
jQuery("#phone a").attr("href", mobile_number);
jQuery("#phone a").attr("text", formatted_number);
};
</script>

 

 

 

IN the body, i have this

 

 

<script>
jQuery( document ).ready( function() {
_googWcmGet(google_conversion_tracking_callback, '888-555-1212')
});
</script>

 

 

 

For some reason, this doesn't work (calls don't register).

 

1) Am I doing this right? If not, where is it going wrong?

2) Do the phone formats have to be identical?

 

 

PS: I know the sample code in google faq says to use body onload, but I can tell you that jQuery(document).ready() is about 99% similar. If someone knows this as otherwise, I'd appreciate any insights.

 

 

 

 

 

 

 

 

 

Re: What is wrong with my Google Website Call Tracking javascript cod

Explorer ✭ ✭ ✭
# 2
Explorer ✭ ✭ ✭

Hi Taewoo,

 

I have also been to the same situation like this. This what I have done accordingly. Note: I haven't used jquery here. But I use only one class across the page for wrapping the number Smiley Happy

 

Step 1 : Add this code before the closing </head>.

 

Spoiler
<script>
var callback = function(formatted_number, unformatted_number) {

var numberLinks = document.getElementsByClassName('number_link');

for (var i in numberLinks) {
numberLinks[i].href = "clkn/tel/" + unformatted_number;
numberLinks[i].innerHTML = "";
numberLinks[i].appendChild(document.createTextNode(formatted_number));
}
};
</script>

<script>
 $(function(){
 _googWcmGet(callback, '8885551212')
 });
</script>

Step 2 : Wrapping the anchor tags on your body area.

 

 

Spoiler
<a href="tel:8885551212" class="number_link" title="Call us!">8885551212</a>

 

 

Key things to node : If your number is wrapped around other tags, wrap your number within the innermost tag.

 

For debugging, use Google Tag Assistant Chrome Extension. It will help you save a lot of time.

 

If you need further clarifications, feel free to ask here.

 

Cheers,

Shafi Ahamed

Re: What is wrong with my Google Website Call Tracking javascript cod

Follower ✭ ✭ ✭
# 3
Follower ✭ ✭ ✭
Hey Shafi. Thanks for that code.

My original code, when tested on Google tag assistant chrome extension, is all green:

http://i.imgur.com/VXUBTig.png

Yet i dont see any conversions firing in adwords w/phone calls.

I will try your approach. Two questions:

1) numberLinks[i].href = "clkn/tel/" + unformatted_number;

What is "clkn/tel/" ?

2) Do the number formats have to be numeric only?

In another words... If my number is "(888) 555-1212".. do i HAVE to use "8885551212" ?

Re: What is wrong with my Google Website Call Tracking javascript cod

Explorer ✭ ✭ ✭
# 4
Explorer ✭ ✭ ✭

hi,

 

1. clkn/tel/ is the structure, i use for all my outbound link clicks, you can remove this accordinly. Sorry I have missed that.

 

2. I have tested using the number with hyphens in between. It can be like 888-555-1212. Both ways, it shouldn't be a problem actually.

 

Added here are examples of formatted phone numbers,

 

Local - 754-3010

Domestic - (541) 754-3010

International - +1-541-754-3010

 

 

Riskier method to debug :

 

It can take up to an hour for your ads to be enabled for this conversion action. If you'd like to make sure it's working, you can do a search that brings up your ad, then click the ad to visit your website (you'll be charged for the click). Your regular phone number should now be replaced with a Google forwarding number.

If you're doing repeated tests, delete the "gwcm" cookie from your browser before clicking on an ad again.

 

Source : https://support.google.com/adwords/answer/6095883?hl=en

 

Hope it will work now Smiley Happy Keep me posted.

 

Cheers,

Shafi Ahamed

Re: What is wrong with my Google Website Call Tracking javascript cod

Follower ✭ ✭ ✭
# 5
Follower ✭ ✭ ✭
I gave up. I'm going to a proprietary solution. I'm wasting money in the thousands.

Thanks Shafi.

Google customer service really sucks.