AdWords
5.4K members online now
5.4K members online now
Improve your AdWords performance and boost your ROI, CTR, and Quality Score
Guide Me
star_border
Reply

Setting up conversion tracking for link clicks

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I found some code online to set-up my conversion code to be activated upon the click of certain links on my website, but after 24 hours, it is not tracking properly. This is the part of my code that it is in, can anyone tell me what is wrong?

 

echo "<tr class=\"search_tr\"><td><img alt=\"" . $d->merchant_name . "\" src=\"" . $d->merchant_image . "\" /></td><td>\$" . $d->price . "</td><td>" . $d->condition_text . "</td><td><input name=\"button2\" type=\"button\" class=\"greenbtnsmall\" value=\"View Detail\" onclick=\"window.open('" . $d->link . "');javascript&colon;trackConv();\"></td></tr>";

 

}

 

echo "</tbody>";

echo "</table>";

 

$sorter = "3: { sorter: false }";

$sort_order = "0";

 

break;

}

 

 

?>

 

<script type="text/javascript">

 

 $(".tablesorter").tablesorter({ 

        // sort on the first column and third column, order asc 

        sortList: [[1,<?php echo $sort_order; ?>]],

textExtraction: function(node) { if ($(node).find("img").length>0) { return $(node).find("img").attr("alt"); } else { return node.innerHTML; } },

headers: { <?php echo $sorter; ?> }

    }); 

 

</script>

 

 

 

 

<script type="text/javascript"> 

function trackConv() { 

        var google_conversion_id                = 1021483684; 

        var google_conversion_label             = 

"cjQ_CIKb4AIQpLWK5wM"; 

        image = new Image(1,1); 

        image.src="http://www.googleadservices.com/pagead/ 

conversion/"+google_conversion_id+"/?label="+google_conversion_label 

+"&script=0"; 

</script> 

1 Expert replyverified_user

Re: Setting up conversion tracking for link clicks

Top Contributor Alumni
# 2
Top Contributor Alumni

Hi

here are some points

1. I am not entirely sure why you are using jacascript function function trackConv()

2. Some of the parameters missing in your conversion code are like:

var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";

var google_conversion_value = 0;

3. also call to conversion.js is missing which looks like

<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js">

I would suggest rather than customizing this code you should just copy and paste the code which you got from adwords conversion. 

Also most imp: in your code pasted if  you have pasted real values for   var google_conversion_id      var google_conversion_label  these parameters in forum please replace them with xxxxx

Hope this helps

 

Regards, Nik
LinkedIn  |   @nikhilparachure | My Blog

Re: Setting up conversion tracking for link clicks

Follower ✭ ✭ ✭
# 3
Follower ✭ ✭ ✭

I think this code is for Call or Application tracking? if it is please tell

Re: Setting up conversion tracking for link clicks

Top Contributor
# 4
Top Contributor

Hi rockthecasbah12,

 

First, a note to Nik: It's being done with a Javascript function because it is being triggered by a click and the conversion code is not on the linked page. This is about the only way to get this done.

 

Ok, the function looks good, but the onclick is bad!

 

You have:

<input name=\"button2\" type=\"button\" class=\"greenbtnsmall\" value=\"View Detail\" onclick=\"window.open('" . $d->link . "');javascript&colon;trackConv();\">

 

The javascript&colon; is what's breaking the script. It is not needed in an onclick defintion and will result in a syntax error. Try it like this:

 

<input name=\"button2\" type=\"button\" class=\"greenbtnsmall\" value=\"View Detail\" onclick=\"trackConv();\">

 

Since there is nothing special going on in the window.open(), that's really not necessary either. What's likely to happen is the new URL opens in the same window (and could possibly load the new URL twice), then the trackConv() never actually runs. Not needed and probably blocking the function, so I removed that, too. This way, the function must run before the new URL opens.

 

This should work for you. When doing stuff like this with conversion tracking, it's usually a good idea to put through a test conversion yourself. Since you don't ever display the image and the link will take you to a different page, you won't be able to determine whether the script executed properly by looking at the page. If you have something like Firebug, you can set a break point at the beginning of the function. If you arrive at the break point after clicking on the link, everything else looks good from there.

 

Best of Luck!

 

Pete

 

petebardo -- Deadhead doing AdWords

Re: Setting up conversion tracking for link clicks

Top Contributor Alumni
# 5
Top Contributor Alumni

Hi petebardo

Thanks for correcting me, the thought didnt occucr to me about it being fired on click and I was too lazy to read complete code. Terribly sorry.

@rockthecasbah12

Tom is absolutely 100% correct Just to add i would suggest you should test your codes with google tag assistant. It will give you details if code is firing or not and if not why.

Hope this helps

 

Regards, Nik
LinkedIn  |   @nikhilparachure | My Blog

Re: Setting up conversion tracking for link clicks

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
onclick=\"window.open('" . $d->link . "') is referencing other code on the page and is required for my page to function. However, I can't find a way to combine the two onclick commands that allows it to still function.

Re: Setting up conversion tracking for link clicks

Top Contributor
# 7
Top Contributor

Hi rockthecasbah12,

 

Ok, I see. I missed that this is a button. Ok, the easy solution here is to reverse the function calls:

 

<input name=\"button2\" type=\"button\" class=\"greenbtnsmall\" value=\"View Detail\" onclick=\"trackConv();window.open('" . $d->link . "');trackConv();\">

 

This will track the conversion first, then open the new URL.

 

Best of Luck!

 

Pete

 

petebardo -- Deadhead doing AdWords

Re: Setting up conversion tracking for link clicks

Top Contributor Alumni
# 8
Top Contributor Alumni

Hi

petebardo

onclick=\"trackConv();window.open('" . $d->link . "');trackConv();

Can you please explain why you are calling trackConv() twice in this code?

Also i think trackConv() adter window.open wouldnt fire.

Am i correct?

Regards

Nik

 

Regards, Nik
LinkedIn  |   @nikhilparachure | My Blog

Re: Setting up conversion tracking for link clicks

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

After implementing this and waiting 24 hours for updated reporting, my conversions still do not track.

Re: Setting up conversion tracking for link clicks

Top Contributor
# 10
Top Contributor

Hey Nik,

 

You are correct, my error. The one after the window.open will never fire, which is why I intended to move the function call to before the window.open.

 

rockthecasbah12, could you possibly provide a URL so I can look at the rendered page? I'm not seeing anything else wrong from here.

 

Pete

 

petebardo -- Deadhead doing AdWords