Conversion pixels are a common type of custom code implemented by our clients. One of the most popular conversion pixel codes is Google Adwords. However, some clients experience issues when using Adwords. Because the Adwords code is not asynchronous, the code as copied from the Adwords website does not work if used on the “results” page. However, the code works as intended when implemented on the “start” page.
The code looks something like this when copied from Adwords:
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1234567890;
var google_conversion_label = "xxx-XXx1xXXX123X1xX";
var google_remarketing_only = "false"
var google_conversion_value = 10.0;
var google_conversion_currency = "USD"
/* ]]> */
</script>
<script type="text/javascript"
src="//www.googleadservices.com/pagead/
conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1234567890/?label=xxx-XXx1xXXX123X1xX"&guid=ON&script=0"/>
</div>
</noscript>
The only part that should be put into the custom code is the code between the noscript tags, but not the noscript tags themselves:
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1234567890/?label=xxx-XXx1xXXX123X1xX"&guid=ON&script=0"/>
</div>
Google Adwords Conversion gtag
Google has created a new Adwords embed code starting in 2018. The code looks like this:
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-1057193461"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-XXXXXX');
</script>
<script>
gtag('event', 'conversion', {'send_to':'AW-XXXXXXX/XXXXXXXXXX'});
</script>
The code needs to be split across the “start” page and the “results” page. The top two scripts should be in the start page and the bottom script should be in the results page, as shown below:
Start Page Code:
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-XXXXXX');
</script>
Results Page Code:
<script>
gtag('event', 'conversion', {'send_to':'AW-XXXXXXX/XXXXXXXXXX'});
</script>