Submitting Google Adwords Conversion Tracking Code via Ajax With Ease

Gary Oosterhuis | October 21, 2014


Placing google adwords conversion tracking within the code that an ajax call makes reference to does not work well with Google. They don’t see to recognize request.

Instead, us the conversion tracking code provided by Google Analtics and modify it as per below. Include this new code once your ajax request is successful.


$.post('/ajax-call-file.php', { }, function(data) {
// GOOGLE ADWORDS CONVERSION TRACKING CODE
// [Part 1] Variables provided by Google Adwords
/* <![CDATA[ */
var google_conversion_id = INSERT_GOOGLE_CONVERSION_ID_HERE;
var google_conversion_language = 'en';
var google_conversion_format = '3';
var google_conversion_color = 'ffffff';
var google_conversion_label = 'INSERT_GOOGLE_CONVERSION_LABEL_HERE';
var google_remarketing_only = false;
/* ]]> */


// [Part 2] Use this in place of the <script> tag provided by Google Adwords
$.getScript('//www.googleadservices.com/pagead/conversion.js');


// [Part 3] Use this in place of the <noscript> and <img> code provided by Google Analytics
var image = new Image(1,1);
image.src = 'http://www.googleadservices.com/pagead/conversion/' +
google_conversion_id + '/?label=' + google_conversion_label +
'&value=1&guid=ON&script=0';
// END OF GOOGLE ANALYTICS TRACKING CODE
});


Link Web Development is a Barrie Website Design and Development company committed to providing quality websites to business owners and other Graphic Design Firms and SEO Experts.

Contact Link Web Development

 

Add a Comment

Your email address will not be published. Required fields are marked *