Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google Adwords conversion script

I have a form, that after submit the form I want to run the script of google Adwords conversion.

I'm using 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 find, the alert message is jump, the script in newLead.php is working. I just don't see the conversion in google adwords.

What can I do?

Of course I changed myConversionId and myConversionLabel to my real details.

Thanks

like image 313
Nir Avatar asked Mar 12 '12 09:03

Nir


People also ask

How do I get a Google Adwords conversion code?

Sign in to your Google Ads account. in the top right-hand corner of your account. Under 'Measurement', click Conversions. In the conversion actions table, find the conversion action that you want to check, then look at the 'Tracking status' column in that same row.

How do I add conversions to Google Ads?

To get started, click on the Tools and Analysis tab in Google Ads, and select Conversions from the drop-down menu, which brings up the All conversions page. Click on the Conversions tab, then click the +Conversion button to create your first conversion.

What is a conversion in Google Adwords?

An action that's counted when someone interacts with your ad or free product listing (for example, clicks a text ad or views a video ad) and then takes an action that you've defined as valuable to your business, such as an online purchase or a call to your business from a mobile phone.

Does Google Ads automatically track conversions?

Also, app downloads and in-app purchases from Google Play, and local actions will automatically be recorded as conversions, and no tracking code is needed.


1 Answers

I just send off the pixel request myself. Something like the following works for me:

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);

That at least registers the conversion, but I'm not sure if there are any issues becuase the actual tracking script isn't loaded.

like image 123
Ewan Heming Avatar answered Oct 17 '22 19:10

Ewan Heming