AdWords
3.8K members online now
3.8K 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

Re: Setting up conversion tracking for link clicks

[ Edited ]
Top Contributor
# 1
Top Contributor

Hi rockthecasbah12,

 

I looked at the page. The window.open() part looks fine, but the trackConv() function call is not included in the onclick event. Place the trackConv() function call before the window.open call, separate them using a semi-colon.

 

Best of Luck!

 

Pete

 

I also looked at the php code you supplied. The trackConv() function definition looks ok, assuming the < and $gt; symbols have been HTML encoded to post here.

 

I looked a little further. There are 2 sections of code that produce the buttons, and they are different. I did not study the code enough to find out why there are 2 sections. There is a switch statement that evaluates $_POST["search_type"]. For case 2,
the code appears to be correct:

 

echo "<tr class=\"search_tr\"><td><img alt=\"" . $d->name . "\" src=\"" . $d->merchant_image . "\" /></td><td>" . $p . "</td><td>" . strtoupper($p->attributes()->condition) . "</td><td><input name=\"button2\" type=\"button\" class=\"greenbtnsmall\" value=\"View Detail\" onclick=\"trackConv();window.open('" . $d->link . "');\"></td></tr>";

 

But that doesn't appear to be the code that is running. There is only one case in the switch statement. If search_type is not 2, here's the code that runs:

 

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 . "');\"></td></tr>";

 

This part does not include your function call to trackConv(), and that's why you're not tracking your conversions. Just add the function call, before the window.open() call, and it should start working for you.

 

PB

 

 

 

 

 

 

petebardo -- Deadhead doing AdWords
1 Expert replyverified_user

Re: Setting up conversion tracking for link clicks

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Pete,

 

When I add the trackconv() function, the link's no longer open.

Re: Setting up conversion tracking for link clicks

Top Contributor
# 3
Top Contributor

Hi rockthecasbah12,

 

It's hard to tell exactly what's going on here. The php code you had provided early was not quite complete. The problem I'm having here is I can not find the trackConv() function definition anywhere on the page, and Javascript can't find it either. When I call trackConv() the error message is "ReferenceError: trackConv is not defined".

 

Is it possible that the calling script for this snippet is already in script context (not html)? After thinking about this a bit, it seems to me the only way to call this file would be in script context That seems very likely as that Javascript code for the function does not appear anywhere on the page. Look at the php error log. I'd be willing to bet you're throwing errors or at least warnings every time the page is generated. You should probably be switching to html context at the top of this file or us an echo statement to output the text.

 

And it also occured to me the script tags may appear in your php files exactly as they appeared in the sample you provided.

 

Try it like this:

 

?>

<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>

 ....

 

 

Best of Luck!

 

Pete

petebardo -- Deadhead doing AdWords

Re: Setting up conversion tracking for link clicks

Top Contributor
# 4
Top Contributor

Hi rockthecasbah12.

 

This piece of javascript does not appear on your page either:

 

<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>

 

 

That's not surprising. Since the last php statement of the script block is a break, the scripting engine never gets there.

 

Pete

 

 

petebardo -- Deadhead doing AdWords

Re: Setting up conversion tracking for link clicks

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
I think I've got it working. Now we'll see if the google tracking will actually work with this method.
Marked as Best Answer.
Solution
Accepted by Zee (Community Manager)
September 2015

Re: Setting up conversion tracking for link clicks

Top Contributor
# 6
Top Contributor

Hi rockthecasbah12,

 

Looks like you've got it right. The function call is in the right place and the function is defined properly. The only thing that could go wrong is if the conversion_id or conversion_label values are wrong.

 

If you don't get conversions everyday, I'd suggest putting through a conversion yourself to test. That means you do a live search and click on your ad.

 

Hope this works! And glad I could help.

 

Pete

 

petebardo -- Deadhead doing AdWords