Google has recently updated the code snippet used to track conversions for AdWords. As of this writing the code in it’s native format will kick back a few errors when attempting to W3C validate. Here is how to fix those errors without breaking the code.

Here is the code in it’s original format.

<!-- Google Code for Lead Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = XXXXXXXXXX;
var google_conversion_language = "en_US";
var google_conversion_format = "X";
var google_conversion_color = "ffffff";
var google_conversion_label = "your_label";
//-->
</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/XXXXXXXXXX/?label=lead&amp;script=0">
</noscript>

Here is the updated code which will now validate. I have highlighted the pieces that have changed. Please note that your entries for the id, language, format, color and label will be different.

<!-- Google Code for Lead Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = XXXXXXXXXX;
var google_conversion_language = "en_US";
var google_conversion_format = "X";
var google_conversion_color = "ffffff";
var google_conversion_label = "your_label";
//-->
</script>
<script language="JavaScript" type="text/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/XXXXXXXXXX/?label=lead&amp;script=0" alt="" />
</noscript>

Please note: this applies to XHTML Transitional doctype written in utf-8 encoding. You may also download this post as a plain text file for easy copy & pasting.

Enjoy!