AJAX表单上的Google AdWords转换?

时间:2017-10-23 15:35:40

标签: javascript jquery ajax google-adwords

客户已要求我们在完成查询表单后将其AdWord转化跟踪代码添加到目标网页,问题是表单是基于AJAX的,因此没有“登录页面”。

我们阅读了很多帖子,并按照指南使用异步AdWords再营销代码

https://developers.google.com/adwords-remarketing-tag/asynchronous/

因此修改此代码:

<!-- Google Code for Footer Contact Form Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
  var google_conversion_id = XXXXXXXXX;
  var google_conversion_language = "en";
  var google_conversion_format = "3";
  var google_conversion_color = "ffffff";
  var google_conversion_label = "XXXXXXXXXXXXXXXXXX";
  var google_remarketing_only = false;
/* ]]> */
</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/XXXXXXXXX/?label=XXXXXXXXXXXXXXXXXX&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

在头部:

<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion_async.js" charset="utf-8"></script>

JS:

$.ajax({
    type: 'POST',
    url: "/contactSend.php",
    data: postData,
    success: function(result) {
        // CONVERSION TRACKING START 
        window.google_trackConversion({
            google_conversion_id: XXXXXXXXX,
            google_conversion_language: "en",
            google_conversion_format: "3",
            google_conversion_color: "ffffff",
            google_conversion_label: "XXXXXXXXXXXXXXXXXX",
            google_remarketing_only: false,
            onload_callback : function() {
                console.log("Conversion Sent Contact");
            }
        });
    }
});

然而,即使控制台登录正确注册,客户端也表示转换未注册。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

上述解决方案是正确的。

在头部,添加:

<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion_async.js" charset="utf-8"></script>

在JS中:

$.ajax({
    type: 'POST',
    url: "/contactSend.php",
    data: postData,
    success: function(result) {
        // CONVERSION TRACKING START 
        window.google_trackConversion({
            google_conversion_id: XXXXXXXXX,
            google_conversion_language: "en",
            google_conversion_format: "3",
            google_conversion_color: "ffffff",
            google_conversion_label: "XXXXXXXXXXXXXXXXXX",
            google_remarketing_only: false,
            onload_callback : function() {
                console.log("Conversion Sent Contact");
            }
        });
    }
});