我正试图跟踪贝宝订单按钮上的点击情况,我的代码看起来像这样.
<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>它工作得很好,我可以看到实时分析报告的事件。
有人能看出我做错了什么吗?
发布于 2013-12-05 01:06:51
我认为您面临的问题是页面导航发生在GA有时间触发事件之前。您可以使用这页面上提供的示例来解决问题。
首先,在头部添加以下内容:
<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">**请注意,我没有测试过这一点,但我知道这样的方法应该有效。一旦你尝试了,但它不起作用,让我知道,我可以找到如果有什么问题在这里。
发布于 2013-12-04 23:13:55
编辑:onclick是窗体的有效属性。,我仍然会使用onsumbit。与其将onsubmit放在<form>标记本身上,不如将其放在input上
<input type="image" onclick="_gag.push(['_trackEvent','Category','Action','Label']);" action="https://www.paypal.com/cgi-bin/webscr" src="http://www.mydomain.com/images/buynow.png" name="submit"/>https://stackoverflow.com/questions/20386794
复制相似问题