我使用了一个 JavaScript 标签,它使用谷歌分析跟踪个人登录用户。它有一个语句“ga('send', 'pageview');”,它会在 Google Analytics 的用户资源管理器中显示特定用户查看过的页面。我想发送事件(我已经在 GTM 中创建)以及参考用户 ID 的网页浏览量,即在我的情况下为 shKey。
这是我的 JS 标签中的代码;
<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-xxxxxxxxx-x' , 'auto');
ga('set', 'userId', arguments.shKey);
ga('set', 'dimension1', arguments.fname);
ga('set', 'dimension2', arguments.type);
ga('send', 'pageview');
ga('send', 'event');
</script>