使用 JavaScript 和 JavaScript 捕获引用 URL 参数传递到谷歌分析
JavaScript 新手。我正在尝试捕获目标页面的引用网址,该页面具有一些结构如下的查询参数:
example.com/vehicle/?stock=12345
一旦获得查询参数,我想使用以下方法将它们传递到 Google Analytics: _gaq.push 方法。我不希望任何人记住 gaq.push 方法,但是我的代码结构正确吗?
<script type="text/javascript">
var vehicleURL=document.referrer;
var stock=vehicleURL.substring(vehicleURL.indexOf('?')+7, vehicleURL.length);
_gaq.push(['track_Event', 'Leads', 'Vehicle', stock]);
</script>
谢谢!
New to javascript. I'm trying to capture the referring url for a goal page, which has some query parameters structured like so:
example.com/vehicle/?stock=12345
Once I get the query parameters, I want to pass them into Google Analytics using the _gaq.push method. I dont' expect anyone to have the gaq.push method memorized, but is my code structured correctly?
<script type="text/javascript">
var vehicleURL=document.referrer;
var stock=vehicleURL.substring(vehicleURL.indexOf('?')+7, vehicleURL.length);
_gaq.push(['track_Event', 'Leads', 'Vehicle', stock]);
</script>
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎走在正确的道路上:
请记住,Google Analytics 对错误的容忍度很小,因此请确保 _gaq.push 正确无误。
You seem to be on the right track:
Keep in mind that Google Analytics has little tolerance for error so make sure that _gaq.push is spot on.