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

Analytics.js - How To Insert Current Page Dynamically as Label

本文关键字:当前页 插入 标签 动态 js- 何动态 Analytics      更新时间:2023-09-26

如何进入这一行:

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

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

谢谢你的帮助!!

对于当前页面URL ,我更喜欢window.location.href而不是document.URL

document.URL

给出页面的当前url

你可以用这个替换你的代码

ga('send', 'event', 'orderform-step-2', 'submitted', document.URL , '10');