Convert Google Adwords script

I have a form, after submitting the form I want to run the Google Adwords conversion script.

I use ajax and jQuery:

var dataString = 'name='+$('#name').val()+'&'+'phone='+$('#phone').val()+'&'+'mail='+$('#mail').val(); $.ajax({ type: "POST", url: "newLead.php", data: dataString, success: function() { alert('Send successfully'); var google_conversion_id = myConversionId; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "myConversionLabel"; var google_conversion_value = 0; $.getScript("http://www.googleadservices.com/pagead/conversion.js"); } }); 

Everything works, a warning message appears, the script in newLead.php is running. I just don't see the conversion to google adwords.

What can I do?

Of course, I changed myConversionId and myConversionLabel to my real data.

thanks

+7
source share
4 answers

I am just sending a request for a pixel. For me, something similar to the following works:

 var img = document.createElement("img"); var goalId = 123456; var randomNum = new Date().getMilliseconds(); var value = 100; var label = "label"; var url = encodeURI(location.href); var trackUrl = "http://www.googleadservices.com/pagead/conversion/"+goalId+"/?random="+randomNum+"&value="+value+"&label="+label+"&guid=ON&script=0&url="+url; img.src = trackUrl; document.body.appendChild(img); 

This at least logs the conversion, but I'm not sure if there are any problems because the actual tracking script is not loaded.

+9
source

Just a guess, but maybe the conversion script expects to see variables in the global scope. In code, you define it in a local area - under a callback

So instead of var google_... write window.google_...

NTN

0
source

I think that the actual conversion appears only after you actually use AdWords (click-through and conversion), so you get conversions in AdWords based on the number of clicks from AdWords, and not from all sources.

Does it make sense?:)

0
source

Look at event tracking, you can associate custom events tracked from your site with Google analytics, and then link everything together with adwords.

Google Video

Event Tracking Guide

We hope that these links will help you.

-one
source

All Articles