|
Page 1 of 2 If you have ever gotten really serious about a Google AdWords account, then you have definitely spent some time setting up AdWords Conversion Tracking. Conversion tracking is so essential to effectively managing an AdWords account that I won't run one without it. In the standard case, it is very easy to setup, you create a conversion, paste the code into your page and you're done. Unfortunately things don't always work out that easily. What if your conversion isn't defined by viewing a page, what if it's downloading a PDF, watching a video, clicking an affiliate link, etc? That's where things get a little bit trickier. I almost lost a client due to my demand of conversion tracking, and that is what forced me to figure out how to track conversions without displaying a "thank you" page.
This article will take you through the process that I use to track conversions using onclick events. Note: the method I prefer relies on jQuery. (Let's face it jQuery really does let you write less and do more). If you would like to learn how to track AdWords Conversions on click events WITHOUT jQuery, then skip to the end of this article to see that snippet of code.
To start out with, let's take a look at the default AdWords Conversion Tracking Code:
<!-- Google Code for Contact Page Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXXXXXXX;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = " XXXXXXXXXXXX";
var google_conversion_value = 0;
/* ]]> */
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/XXXXXXXXXXXX/?label=XXXXXXXXXXXX&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
The code here is pretty straight-forward, you set some variables so that Google knows that type of conversion pixel to display, things like ID, colors, labels, etc. Then you call a script from one of Google's domains which takes the variables you just set and displays a conversion pixel (and the little privacy notification if you selected that option when you created the conversion). The trick here is that you can just call a function when someone clicks on your download link to track that download as a conversion in AdWords, because you have to actually call that "conversion.js" from Google's server in order to get it to track.
The answer to tracking conversions on click events turns out to be a little counter-intuitive. Clearly, we'll need to use some sort of Javascript to get this done, but our Javascript code will actually use the <noscript> portion of the AdWords Conversion script. Most people never look at the <noscript> part. I even know a developer who leaves it out when he sets up conversion tracking, because his business depends so much on technology that if you don't have Javascript enabled, then you're not his target market (even if you do sign up for his newsletter), but I digress...
If you take a look at the <noscript> part of the AdWords Conversion Script, you'll see that all it does is display an image, with a source URL that uses the same 'google_conversion_id' and 'google_conversion_label' from the traditional script. With that in mind, we can track conversions just by displaying an <img> with the right URL in the source. Pretty simple, right? OK, so on to the code.
|