JavaScript onClick Google AdWords Conversion Tracking

This is really just a technique in converting the provided Google AdWords Conversion Tracking Code, and it is really simple.

Take the conversion code provided, usually something like:

<!-- Google AdWords Code for Conversion Page -->
<script language="JavaScript" type="text/javascript">
var google_conversion_id = 1234567890;
var google_conversion_language = "en_US";
var google_conversion_format = "1";
var google_conversion_color = "666666";
if(1){
var google_conversion_value = 1;
}
var google_conversion_label = "Purchase";
</script>
<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0 src="http://www.googleadservices.com/pagead/conversion/1234567890/?value=1&label=Purchase&script=0">
</noscript>

And convert it into this:

<script>
var uniqueConversionFunctionName = function(){
var image = new Image(1,1);
image.src = "http://www.googleadservices.com/pagead/conversion/1234567890/?value=1&label=Purchase&script=0";
return;
}
</script>

Notice that in the second block of code above, I've taken the source of the image which was provided by Google in the first block of code's noscript tag.

That's it! with this your Google AdWords conversion no longer has to be a landing page, it can be a button click event, or whatever else you want it to be.

© Erik Vold 2007-2010. Contact Erik Vold. Top ^