如何跟踪 Google Adwords 点击转化?

发布于 2024-08-18 07:57:44 字数 1073 浏览 15 评论 0原文

如果有人点击链接,Google AdWords 不会提供任何代码来添加到您的页面来计算转化。但由于它是 Javascript,我确信有办法做到这一点。

这是 Google 为您提供的包含在页面中的代码(未更改),该代码应算作一次转化(大多数情况下是感谢页面):

<!-- Google Code for Klick Conversion Page -->
<script type="text/javascript">
<!--
var google_conversion_id = 1062751462;
var google_conversion_language = "de";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "dKXuCODvugEQ5pnh-gM";
var google_conversion_value = 0;
//-->
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1062751462/?label=dKXuCODvugEQ5pnh-gM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

对于其他转化跟踪脚本,必须执行某些函数来计算转化。在这里,只需将 JS 文件添加到您的页面就足以触发转换跟踪,因为 conversion.js 会在加载时调用一个函数(下载它并通过代码美化器运行后查看它,这确实是相当不错的工作!)。

知道如何解决这个问题吗?

Google Adwords offers no code to add to your page to count a conversion if somebody clicks on a link. But as it's Javascript, I am sure there is a way to do this.

Here's the code (unaltered) Google gives you to include in the page, that should count as a conversion (most of the time a thank you page):

<!-- Google Code for Klick Conversion Page -->
<script type="text/javascript">
<!--
var google_conversion_id = 1062751462;
var google_conversion_language = "de";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "dKXuCODvugEQ5pnh-gM";
var google_conversion_value = 0;
//-->
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1062751462/?label=dKXuCODvugEQ5pnh-gM&guid=ON&script=0"/>
</div>
</noscript>

With other conversion tracking scripts some function has to be executed to count the conversion. Here, just adding the JS-File to your page can be enough to trigger the conversion-tracking, as conversion.js calls a function on load (download it and look at it after running it through a code beatuifier, it's really quite nice work!).

Any idea how to tackle this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

久夏青 2024-08-25 07:57:44

不知道您是否已经找到它...无论如何我都会为未来的冲浪者提到它...

我一直在寻找相同的东西,并找到了这段代码:

<script type="text/javascript"> 
    function trackConv(google_conversion_id, google_conversion_label) {
        var image = new Image(1, 1); 
        image.src = "//www.googleadservices.com/pagead/conversion/" + google_conversion_id + "/?label=" + google_conversion_label + "&script=0";  
    }
 </script>

然后对于您想要跟踪的链接只需执行以下操作:

<a onclick="trackConv(1234567890, 'LQV8CNq6RxCKlPbvAw');" href="http://www.example.com">Link</a> 

Don't know if you've already found it... I mention it anyway for future surfers...

I was looking for the same, and found this piece of code :

<script type="text/javascript"> 
    function trackConv(google_conversion_id, google_conversion_label) {
        var image = new Image(1, 1); 
        image.src = "//www.googleadservices.com/pagead/conversion/" + google_conversion_id + "/?label=" + google_conversion_label + "&script=0";  
    }
 </script>

Then for links which you want to track just do this :

<a onclick="trackConv(1234567890, 'LQV8CNq6RxCKlPbvAw');" href="http://www.example.com">Link</a> 
痕至 2024-08-25 07:57:44

Google 现在似乎提供了一个 onclick 选项,您可以从 AdWords 的“转化”页面复制并粘贴该选项。从 AdWords 转化页面:

将该标记添加到您网站上的按钮,例如“立即购买”按钮。

以下是标题为跟踪网站上的点击次数的文档页面的片段。将 XXXXX 替换为转换 ID 和标签:

<!-- Google Code for Conversion Page
In your html page, add the snippet and call
goog_report_conversion when someone clicks on the
chosen link or button. -->
<script type="text/javascript">
  /* <![CDATA[ */
  goog_snippet_vars = function() {
    var w = window;
    w.google_conversion_id = XXXXXXX;
    w.google_conversion_label = "XXXXXXX";
    w.google_remarketing_only = false;
  }
  // DO NOT CHANGE THE CODE BELOW.
  goog_report_conversion = function(url) {
    goog_snippet_vars();
    window.google_conversion_format = "3";
    var opt = new Object();
    opt.onload_callback = function() {
    if (typeof(url) != 'undefined') {
      window.location = url;
    }
  }
  var conv_handler = window['google_trackConversion'];
  if (typeof(conv_handler) == 'function') {
    conv_handler(opt);
  }
}
/* ]]> */
</script>
<script type="text/javascript"
  src="//www.googleadservices.com/pagead/conversion_async.js">
</script>

以及代码中的其他位置

button.addEventListener('click', function() {
  console.log('Button clicked!');
  goog_report_conversion();
});

It appears that Google now offers an onclick option that you can copy and paste from the Conversions page in AdWords. From the AdWords Conversions page:

Add the tag to a button on your website, such as a "Buy now" button.

Here's a snippet from the page of documentation entitled Track clicks on your website as conversions. Replace XXXXX with conversion ID and label:

<!-- Google Code for Conversion Page
In your html page, add the snippet and call
goog_report_conversion when someone clicks on the
chosen link or button. -->
<script type="text/javascript">
  /* <![CDATA[ */
  goog_snippet_vars = function() {
    var w = window;
    w.google_conversion_id = XXXXXXX;
    w.google_conversion_label = "XXXXXXX";
    w.google_remarketing_only = false;
  }
  // DO NOT CHANGE THE CODE BELOW.
  goog_report_conversion = function(url) {
    goog_snippet_vars();
    window.google_conversion_format = "3";
    var opt = new Object();
    opt.onload_callback = function() {
    if (typeof(url) != 'undefined') {
      window.location = url;
    }
  }
  var conv_handler = window['google_trackConversion'];
  if (typeof(conv_handler) == 'function') {
    conv_handler(opt);
  }
}
/* ]]> */
</script>
<script type="text/javascript"
  src="//www.googleadservices.com/pagead/conversion_async.js">
</script>

And somewhere else in your code

button.addEventListener('click', function() {
  console.log('Button clicked!');
  goog_report_conversion();
});
待天淡蓝洁白时 2024-08-25 07:57:44

我有类似的问题。

问题:
我的客户有一个带有表格的联系页面。用户填写所有表单字段后,将进行验证(检查用户是否正确填写了所有字段)。验证后,用户将被重定向到网络邮件服务器页面。没有“成功”或“谢谢”页面。所以我需要在表单验证之后添加 Adwords 标签。

解决方案:

验证是这样完成的:

var missinginfo = "";
var f = document.forms["CONTACT"];
if (f.name.value == ""){
missinginfo += "\n     -  name";}
.
.
.
if (missinginfo != "") 
{
missinginfo ="_____________________________\n" +
"Empty Field" + "incorrectly filled" +
missinginfo + "\n_____________________________"
alert(missinginfo);
return false;
}
//End of Validation

所以我添加了这个片段代码:

else if(missinginfo == ""){   //Check if the form was filled correctly
adw_conv();  //Function Name
return false;
}
function adw_conv(){
var img = new Image()  //Creates an image using JS to make the request
img.src = "http://www.googleadservices.com/pagead/conversion/123456789/?label=-8bcaCNHv6AIQl_v8_QM&guid=ON&script=0"; 
img.onload = function(){    
var form = document.getElementsByName('CONTACT')[0];
form.submit();
}}

这样,在表单验证之后和网站将用户重定向到网络邮件页面之前,就会触发 AdWords 转换!

I've a similar problem.

The Problem:
My client have a contact page that have a form. After the user fill all the form fields, there is a validation(to check if the user filled correctly all the fields). After the validation, the user is redirected to the webmail server page. There isn't an "Success" or "Thank You" page. So i needed to put the Adwords tag, after the form validation.

The Solution:

The validation was done this way:

var missinginfo = "";
var f = document.forms["CONTACT"];
if (f.name.value == ""){
missinginfo += "\n     -  name";}
.
.
.
if (missinginfo != "") 
{
missinginfo ="_____________________________\n" +
"Empty Field" + "incorrectly filled" +
missinginfo + "\n_____________________________"
alert(missinginfo);
return false;
}
//End of Validation

So i added this snippet code:

else if(missinginfo == ""){   //Check if the form was filled correctly
adw_conv();  //Function Name
return false;
}
function adw_conv(){
var img = new Image()  //Creates an image using JS to make the request
img.src = "http://www.googleadservices.com/pagead/conversion/123456789/?label=-8bcaCNHv6AIQl_v8_QM&guid=ON&script=0"; 
img.onload = function(){    
var form = document.getElementsByName('CONTACT')[0];
form.submit();
}}

This way, after the form validation and before the website redirect the user to the webmail page, is triggered the Adwords Conversion!

蓝礼 2024-08-25 07:57:44

在提交按钮上使用 Ajax 的 Google 转化跟踪概念:

 $.ajax({
        type: "POST",
        url: "enquiry-submit.php",
        data: data,
        success: function (result) {
          $("#msg").fadeIn(400).html(result);

          /* Conversion Tracking Start */
          var google_conversion_id = YOUR_CONVERSION_ID_HERE;
          var google_conversion_language = "en";
          var google_conversion_format = "3";
          var google_conversion_color = "ffffff";
          var google_conversion_label = "YOUR_CONVERSION_LABEL_HERE";
          var google_remarketing_only = false;

          $.getScript('//www.googleadservices.com/pagead/conversion.js');

          var image = new Image(1, 1); 
          image.src = "//www.googleadservices.com/pagead/conversion/YOUR_CONVERSION_ID_HERE/?label=YOUR_CONVERSION_LABEL_HERE&guid=ON&script=0";  
          /* Conversion Tracking End */
        }
      });

它在我的 Google Ads 广告系列中 100% 有效。

注意:您必须通过点击广告来进行测试。 12 分钟后,您将在 AdWords 控制台上看到转化效果

Google Conversion Tracking concept using Ajax on a submit button :

 $.ajax({
        type: "POST",
        url: "enquiry-submit.php",
        data: data,
        success: function (result) {
          $("#msg").fadeIn(400).html(result);

          /* Conversion Tracking Start */
          var google_conversion_id = YOUR_CONVERSION_ID_HERE;
          var google_conversion_language = "en";
          var google_conversion_format = "3";
          var google_conversion_color = "ffffff";
          var google_conversion_label = "YOUR_CONVERSION_LABEL_HERE";
          var google_remarketing_only = false;

          $.getScript('//www.googleadservices.com/pagead/conversion.js');

          var image = new Image(1, 1); 
          image.src = "//www.googleadservices.com/pagead/conversion/YOUR_CONVERSION_ID_HERE/?label=YOUR_CONVERSION_LABEL_HERE&guid=ON&script=0";  
          /* Conversion Tracking End */
        }
      });

It is 100% working on my Google Ads Campaign.

Note: You must Test this by clicking on your ad. The effect of conversion will be visible after 12 minute on your AdWords Console

所谓喜欢 2024-08-25 07:57:44

将以下代码添加到您要跟踪转化的页面部分。

<script>
function adwTrack() {
   var img = new Image(1,1);
   img.src =     "https://www.googleadservices.com/pagead/conversion/XXXXXXXXXX/?value=1.00&currency_code=EUR&label=XXXXXXXXXX&guid=ON&script=0";

}

只需将 XXX... 替换为您的实际转化 ID 和标签即可。

然后在链接的 onclick 事件中调用我们上面创建的 adwTrack() 函数:

<a href="#" onclick="adwTrack();">Track This</a>

您也可以使用 GTM 执行此操作:https://www.redflymarketing.com/blog/track-conversions-without-a-thank-you-page/

Add the code below to the section of the page you want to track conversions on.

<script>
function adwTrack() {
   var img = new Image(1,1);
   img.src =     "https://www.googleadservices.com/pagead/conversion/XXXXXXXXXX/?value=1.00&currency_code=EUR&label=XXXXXXXXXX&guid=ON&script=0";

}

Just replace the XXX… with your actual conversion id and label.

Then call the adwTrack() function we created above in your link’s onclick event:

<a href="#" onclick="adwTrack();">Track This</a>

You can also do this using GTM: https://www.redflymarketing.com/blog/track-conversions-without-a-thank-you-page/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文