如何在Google Analytics(分析)脚本中设置userId的格式? [英] How to format the userId in Google Analytics script?

查看:194
本文介绍了如何在Google Analytics(分析)脚本中设置userId的格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的静态HTML网站,我将此推荐的脚本代码嵌入到页面的每一页中。

for my static HTML webside I embedded this recommended script code to every page of the side.

<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-96597161-1', 'auto');
ga('send', 'pageview');

ga('set', 'userId', {{USERID}});

问题是:
如何将我已知的Google Analytics(分析)用户ID格式化到 {{USERID}} 的位置?
是带括号吗?,带引号吗?
感谢您的帮助。

The question is: how to format my known Google analytics userId into this place {{USERID}}? Is it With brackets?, with quotes? Thanks for your help.

推荐答案

analytics.js字段引用将UserID列为格式为文本,这意味着您可以像其他任何类型一样传递

The analytics.js fields reference lists UserID as format type "text", which means you pass it in like you would any other string value in Javascript (i.e. in as quoted string).

实际上同一页面上有示例:

In fact the same page has examples:

// Set the user ID when creating the tracker.
ga('create', 'UA-XXXX-Y', {'userId': 'as8eknlll'});

// Alternatively, you may set the user ID via the `set` method.
ga('set', 'userId', 'as8eknlll');

这篇关于如何在Google Analytics(分析)脚本中设置userId的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆