【发布时间】:2020-07-10 18:36:49
【问题描述】:
我正在尝试编写一个函数,该函数将用于 Google 跟踪代码管理器 (GTM) 中的自定义 Javascript 变量。我目前拥有的是以下内容:
function getClientID()
{ // Modify customDimensionIndex to match the index number you want to send the data to\n
var customDimensionIndex = 7;
return function(model)
{
model.set('dimension' + customDimensionIndex, model.get('clientId'));}
}
它应该获取客户端 ID,并将 Google Analytics(分析)自定义维度的索引(在本例中为 7)设置为它。 但是,这不会在页面上返回客户端 ID。 GTM预览模式下,有SessionID和SitecoreUserID,如下:
user:
{ sitecoreID: '00000000-0000-0000-0000-000000000000',
...
},
session:
{ id: 'aa2aaaaqaaaaaaaaaaa25eee'}
我想我可以使用 sitecoreID 作为客户端 ID 并将其发送到 Google Analytics。但是我想知道页面上通常是否会有另一个客户端 ID,如果有,如何获取?
提前致谢。
【问题讨论】:
-
这会将客户 ID 作为自定义维度发送,前提是您将其用作 Universal Analytics 代码上的自定义任务。在任务之外,您将无法访问模型。
-
谢谢。那么该模型是 UA 标签所独有的吗?然后应该可以使用了吧
标签: javascript google-analytics sitecore google-tag-manager clientid