Google Analytics中的UserID或Fix用户跟踪

时间:2016-06-09 11:50:44

标签: html google-analytics

如果我有100位客户,&每个客户都可以在登录后插入我的网站,

我想通过登录我网站的谷歌分析来跟踪用户ID?请给我最好的解决方案?

我需要在我的网站中添加哪些代码或如何在Google Analytics中设置跟踪代码?

1 个答案:

答案 0 :(得分:0)

<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto'); //UA-XXXXX-Y place your GA tracking code instead this
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

 ga('send', 'event', 'Login', 'User', 'userID#'+userID); // place your  userID