Ajax 请求上的 GA 跟踪代码?

发布于 2024-12-07 20:29:37 字数 947 浏览 4 评论 0原文

我有这个:

<!-- Google Code for Tilmeldinger nyhedsbrev Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ /
var google_conversion_id = 982857669;
var google_conversion_language = "da";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "e90GCIP3jwMQxe_U1AM";
var google_conversion_value = 0;
if (20) {
google_conversion_value = 20;
}
/ ]]> */
</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/982857669/?value=20&label=e90GCIP3jwMQxe_U1AM&guid=ON&script=0"/>
</div>
</noscript>

我将它插入到ajax请求的页面上,并在响应中看到这个脚本^。

但它不跟踪或计算任何东西?

我应该怎么办?

I have this:

<!-- Google Code for Tilmeldinger nyhedsbrev Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ /
var google_conversion_id = 982857669;
var google_conversion_language = "da";
var google_conversion_format = "1";
var google_conversion_color = "ffffff";
var google_conversion_label = "e90GCIP3jwMQxe_U1AM";
var google_conversion_value = 0;
if (20) {
google_conversion_value = 20;
}
/ ]]> */
</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/982857669/?value=20&label=e90GCIP3jwMQxe_U1AM&guid=ON&script=0"/>
</div>
</noscript>

I inserted it on the page the ajax request to, and in the response I see this script^.

But it does not track or count anything?

What should I do?

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

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

发布评论

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

评论(2

陪你搞怪i 2024-12-14 20:29:37

当 AJAX 请求返回时,脚本不会被执行。您可以尝试找出原因,或者我认为 位无论如何都完成了大部分工作,因此您可以尝试删除其余部分并将图像放入页面中:

<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/982857669/?value=20&label=e90GCIP3jwMQxe_U1AM&guid=ON&script=0"/>

这应该是问题将跟踪数据发送到 AdWords 的图像请求。

The script's not being executed when the AJAX request returns. You can either try and figure out why, or I think the <noscript> bit does most of the work anyway so you could try removing the rest and just placing the image into your page:

<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/982857669/?value=20&label=e90GCIP3jwMQxe_U1AM&guid=ON&script=0"/>

This should issue an image request that sends the tracking data to AdWords.

半边脸i 2024-12-14 20:29:37

您可以使用 GA 事件的跟踪。以下是您需要的所有信息:http://code.google.com/ apis/analytics/docs/tracking/eventTrackerGuide.html

我建议您编写小函数:

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

  function event(category, action, label, value) {
    _gaq.push(['_trackEvent', category, action, label, value]);
  }

并调用 event() 函数。

You can use the GA event's tracking. Here is all info you need: http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

I suggest you to write small function:

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

  function event(category, action, label, value) {
    _gaq.push(['_trackEvent', category, action, label, value]);
  }

And jsut call event() function.

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