jquery 移动子页面上的 Google AdWords 转化跟踪

发布于 2025-01-08 18:41:35 字数 135 浏览 0 评论 0 原文

我在 jquery 移动页面中有一个子页面,我想在其中插入 att Google adwords 转换 cookie。但使用 AdWords 中的传统代码片段是行不通的。在 Android 上,它甚至会使页面变成空白。

以前有人这样做过吗?

I have a subpage in a jquery mobile page where I'd like to insert att Google adwords conversion cookie. But using the traditional snippet from Adwords doesn't work. On Android it even makes the page go blank.

Anyone done this before?

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

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

发布评论

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

评论(2

治碍 2025-01-15 18:41:35

您可能稍后会通过执行以下操作在页面上加载转换脚本:

(function(){
    var s=document.getElementsByTagName('script')[0];
    var ga=document.createElement('script');
    ga.type='text/javascript';
    ga.async=true;
    ga.src='http://www.googleadservices.com/pagead/conversion.js';
    s.parentNode.insertBefore(ga,s);
})();

或者使用 jQuery 函数加载与上述函数类似的脚本。事实证明,您不能以这种方式包含 conversion.js 脚本,因为它使用 document.write 在页面上写入 img 标签。因为它使用 document.write ,一些浏览器会删除页面中的所有内容,并用 document.write 的输出替换内容,在本例中是一个空的 gif。

您最好使用谷歌提供的默认标签来标记转化。如果您需要在不刷新页面的情况下加载它,只需打开包含此跟踪代码的页面的 iframe 即可。

<script type="text/javascript"> 
  var google_conversion_id = 1234567890;
  var google_conversion_language = "en_US";
  var google_conversion_format = "1";
  var google_conversion_color = "666666";
  var google_conversion_label = "Purchase";
  if (10.0) {
    var google_conversion_value = 10.0
  }
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
  <img height=1 width=1 border=0 
  src="http://www.googleadservices.com/pagead/conversion/1234567890/?value=10.0&label=Purchase&script=0">
</noscript>

当然这只是一个例子。您应该使用您自己的具有唯一 conversiod_id 的代码。

You are probably loading the conversion script later on the page by doing something like this:

(function(){
    var s=document.getElementsByTagName('script')[0];
    var ga=document.createElement('script');
    ga.type='text/javascript';
    ga.async=true;
    ga.src='http://www.googleadservices.com/pagead/conversion.js';
    s.parentNode.insertBefore(ga,s);
})();

Or using a jQuery function to load scripts that is similar to the function above. Turns out that you can't include the conversion.js script in this manner because it uses document.write to write the img tag on the page. Because it uses document.write some browsers will remove everything from the page and replace the content with the output of document.write, which in this case is an empty gif.

You better use the default tag provided by google to mark a conversion. If you need to load it without a page refresh just open an iframe to a page that contains this tracking code.

<script type="text/javascript"> 
  var google_conversion_id = 1234567890;
  var google_conversion_language = "en_US";
  var google_conversion_format = "1";
  var google_conversion_color = "666666";
  var google_conversion_label = "Purchase";
  if (10.0) {
    var google_conversion_value = 10.0
  }
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
  <img height=1 width=1 border=0 
  src="http://www.googleadservices.com/pagead/conversion/1234567890/?value=10.0&label=Purchase&script=0">
</noscript>

Of course this is just an example. You should use your own code that have your unique conversiod_id.

物价感观 2025-01-15 18:41:35

我对此进行了一些研究,发现了以下链接:

因此,根据您所投放的广告类型,您将必须获得一个定制的移动设备。

但是,我仍然不确定为什么页面会变成空白。我的意思是,当您尝试延迟加载某些广告代码时,我完全可以理解它是如何做到这一点的,但我不确定为什么会在您的情况下发生这种情况。

I researched this a bit, and came across the following links:

So it looks like depending on the type of ad you're running, you will have to get a customized unit for mobile.

However, I am still not sure why the page would go blank. I mean, I can totally see how some ad code does that when you try to lazy-load it, but I'm not sure why it happens in your situation.

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