本文介绍了Google Analytics-Gtag用户ID问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
到目前为止,我一直在尝试将user_id发送到Google Analytics(分析),但没有成功.我按照控制台上的说明进行操作,基本上是按照以下步骤设置"user_id":
I've been trying to send user_id to google analytics with no success so far. I followed the instructions on the console which is basically to set the 'user_id' as follows:
<script async src="https://www.googletagmanager.com/gtag/js?id=XXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'XXXXX', {'user_id': '{{ user.id }}'});
</script>
我读过的大部分线程都是用旧方法配置的:ga
Most of the thread i've read was to configure in the old way: ga
推荐答案
按照文档,您应该这样设置:
As per documentation , you should be setting it like so:
gtag('config', 'GA_TRACKING_ID', {
'user_id': 'USER_ID'
});
这篇关于Google Analytics-Gtag用户ID问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!