这与使用gtag在Google Analytics(分析)调用中设置用户ID有关。
1。)文档说要这样设置用户ID:
gtag('config','GA_MEASUREMENT_ID',{
'user_id': 'USER_ID'
});
(参考:https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id)
2。)但是,当在分析控制台中实际设置用户ID功能时,那里的说明说要以这种方式设置用户ID:
gtag('set',{'user_id': 'USER_ID'}); // Set the user ID using signed-in user_id.
// The value must be set for all hits in the session. We recommend using the set method to ensure all additional Analytics hits on the page contain this value.
那么...哪个最好,为什么?谢谢!