我正在尝试跟踪Paypal订单按钮上的点击,我的代码如下所示。

<form onclick="_gag.push(['_trackEvent','Category','Action','Label']);" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="FV4TYGHXWUGHT">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Test Item">
<input type="hidden" name="amount" value="5.00"><input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="hidden" name="custom" value="">
<input type="hidden" name="notify_url" value="http://www.mydomain.com/notify.html">
<input type="hidden" name="return" value="http://www.mydomain.com/return.html">
<input type="image" src="http://www.mydomain.com/images/buynow.png" name="submit"/>
<img style="margin-top:20px;" alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>


这不起作用,当单击时不会触发任何事件,其他方面,如果我使用此功能,分析在页面上也可以正常工作。

<a href="http://www.testurl.com" target="_blank" onclick="_gaq.push(['_trackEvent', 'Click-Through', 'Test1', 'Test2']);">TEST LINK</a>


它工作正常,我可以在实时分析中看到该事件

谁能看到我做错了吗?

最佳答案

我认为您所面临的问题是页面导航发生在GA有时间触发事件之前。您可以使用this页上提供的示例来解决您的问题。

首先,将以下内容添加到头部:

<script type="text/javascript">
function trackOutboundLink(form, category, action, label) {

try {
_gaq.push(['_trackEvent', category , action, label]);
} catch(err){}

  setTimeout(function() {
    form.submit();
  }, 100);
}
</script>


然后,按以下方式更改跟踪:

<form onsubmit="trackOutboundLink(this, 'category', 'action', 'label'); return false;" action="https://www.paypal.com/cgi-bin/webscr" method="post">


**请注意,我尚未对此进行测试,但是我知道类似的东西应该可以工作。一旦您尝试了一下,但它不起作用,请告诉我,我可以在这里找到问题。

10-06 07:47
查看更多