Analytics.js - 如何动态插入当前页面作为标签

时间:2014-10-27 21:48:57

标签: javascript jquery google-analytics

我怎样才能进入这一行:

<script type="text/javascript">
$('form').submit(function() {
  ga('send', 'event', 'orderform-step-2', 'submitted', 'http://example.com/page1', '10');
});
</script>

=&GT;动态插入“http://example.com/page1”?这是Google Analytics事件标签值,因此对于跟踪视频,不同的订单等等非常有用。

感谢您的帮助!!

2 个答案:

答案 0 :(得分:1)

document.URL

给出页面的当前网址

您可以使用此

替换您的代码
ga('send', 'event', 'orderform-step-2', 'submitted', document.URL , '10');

答案 1 :(得分:1)

对于当前页面网址

,我更喜欢window.location.href而不是document.URL