1

我正在尝试衡量我的 Google Adwords 广告系列的转化率和进入 App Store 的正常流量。以前我的页面上有一个链接“/app_store/”,它会加载,等待 1 秒,然后继续访问应用商店。

我在某处使用 Javascript 找到了更优雅的解决方案。对于 adwords,它加载一个像素图像,对于分析,它调用一个 Google Javascript 函数,暂停几分之一秒,然后跟随链接。

不幸的是,它对我不起作用。Google Analytics 和 Google Adsense 没有看到任何人进入 App Store(甚至我自己也没有)。

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-18180332-1']);
  _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 recordOutboundLink(link, category, action) {
    try{
        // Google Analytics
        var pageTracker = _gat._getTracker("UA-18180332-1");
        pageTracker._trackEvent(category, action);

        // Google Adwords
        var image = new Image(1, 1);
        image.src = "http://www.googleadservices.com/pagead/conversion/1046551421/?value=$8&amp;label=zqrfCMWh0QEQ_baE8wM&amp;guid=ON&amp;script=0"
        setTimeout('document.location = "' + link.href + '"', 100)

    } catch(err) {}
}
</script>

对于链接:

<a href="http://itunes.apple.com/ae/app/isimplifiedchinese/id377690407?mt=8"
onClick="recordOutboundLink(this, 'Outbound Links', 'http://itunes.apple.com/ae/app/isimplifiedchinese/id377690407?mt=8');return false;">
<img alt="Appstore" src="images/appstore.png"></a>

我在这里做错了什么?

更新 23:13 我注意到如果延迟为 100 毫秒,则以下错误会闪烁(我花了一段时间才对屏幕截图进行计时)。

无法加载资源

我只根据 Erwan 的建议对此进行了测试;不知道它是否也发生在旧版本中。该错误似乎会随着更长的延迟而消失;为了安全起见,我将其设置为 300 毫秒。

4

3 回答 3

0

您应该防止单击操作(浏览到链接)在您记录之前执行。在 onclick 属性上添加一个“return false”:

onclick="recordOutboundLink(params);return false;"

希望能帮助到你

于 2011-02-23T13:35:42.490 回答
0

我已经设法让我的工作与_gaq.push();

代替:

var pageTracker = _gat._getTracker("UA-18180332-1");
pageTracker._trackEvent(category, action);

做:

_gaq.push(['_trackEvent', category, action]);

所以不要再次获取 pageTracker,因为 _gaq 在页面启动时已经被初始化。只需使用 _gaq 推送事件跟踪器。另外,请记住,谷歌分析不会实时更新,而且通常不会在 48 小时内更新。

于 2011-02-23T13:36:33.387 回答
0

在 GA 代码完成运行之前,脚本可能正在重定向。您可以尝试将它放在 gaq 上,这样它就可以保证在其余代码之后运行。您的函数可能如下所示:

function recordOutboundLink(link, category, action) {
    // Google Analytics
    _gaq.push(['_trackEvent', category, action]);

    // Google Adwords
    _gaq.push(function() {
    var image = new Image(1, 1);
    image.src = "http://www.googleadservices.com/pagead/conversion/1046551421/?value=$8&amp;label=zqrfCMWh0QEQ_baE8wM&amp;guid=ON&amp;script=0";
    });
    _gaq.push(function() {setTimeout('document.location = "' + link.href + '"', 100);});
}

我还没有测试过,但它与我之前尝试过的类似。

于 2011-02-23T14:03:05.950 回答