google Adwords conversion script

别等时光非礼了梦想. 提交于 2019-11-29 14:35:23

问题


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


回答1:


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.




回答2:


Just a guess, but may be conversion script expects to see it's variables in Global scope. In your code you define it in local scope - under callback

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

HTH




回答3:


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

Does it make sense? :)




回答4:


Have a look at Event tracking, you can link custom events tracked from your website to your google analytics, then link everything together with adwords.

Video by google

Events tracking guide

Hope these links will help you out.



来源:https://stackoverflow.com/questions/9664695/google-adwords-conversion-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!