客户 ID 和身份验证状态 customer-ids-and-authentication-states
除了ECID之外,您还可以将其他的客户ID和身份验证状态与每位访客关联。
身份验证状态 section-68ad4065dfaa437d9070832d6e2bf85c
setCustomerIDs 方法可以接受同一访客拥有多个客户 ID。 这有助于您识别或锁定跨不同设备的单独用户。 例如,您可以将这些ID作为客户属性上传到CX Enterprise,并在不同的解决方案中访问此数据。
IMPORTANT
客户属性和核心服务功能要求使用
setCustomerIDs(客户 ID 同步)。 同步客户ID是一种适用于Analytics的可选识别方法。 Target需要Visitor.AuthState.AUTHENTICATED才能使客户属性正常工作。 请参阅核心服务 - 如何启用您的解决方案,以了解相关示例。从访客ID服务版本1.5开始,setCustomerIDs包含可选的AuthState对象。 AuthState 可根据访客的身份验证状态(例如,已登录,已注销)来识别他们。 使用表中列出的状态值来设置身份验证状态。 将作为整数返回身份验证状态。
身份验证状态
状态整数
用户状态
Visitor.AuthState.UNKNOWN
0
未知或从未验证。
未对访客 ID 使用 AuthState,或未在每个页面或应用程序上下文中显式设置此属性时,默认应用未知状态。
Visitor.AuthState.AUTHENTICATED
1
已经过特定实例、页面或应用程序的验证。
注意:要正常使用,Target 的用户属性需要此状态。
Visitor.AuthState.LOGGED_OUT
2
已注销。
身份验证状态用例 section-fe9560cc490943b29dac2c4fb6efd72c
您可以根据用户对 Web 属性执行的操作以及他们是否进行了身份验证,来为用户分配身份验证状态。 请查看下表中的一些示例:
身份验证状态
用例
Visitor.AuthState.UNKNOWN
此状态可用于以下场景:
- 阅读电子邮件(这项操作可能意味着读者是预期的收件人,但电子邮件也可能已被转发)。
- 从电子邮件点击进入登陆页面。
Visitor.AuthState.AUTHENTICATED
用户目前通过了您网站或应用程序上活动会话的身份验证。
Visitor.AuthState.LOGGED_OUT
用户已完成身份验证,但已主动注销。 用户打算从已完成身份验证状态断开连接。 用户不希望再被视为已进行身份验证。
设置客户 ID 和身份验证状态 section-ec4b367d16ad4ac1a1baca9b01f4ee98
客户 ID 可包含 ID 和身份验证状态的组合,如以下示例中所示。
IMPORTANT
- ID 区分大小写。
- 仅将未编码的值应用于您的 ID。
- 客户 ID 和身份验证状态未存储在访客 ID Cookie 中。 必须为每个页面或应用程序上下文设置这些值。
- 您不应在客户 ID 中包含任何个人身份信息 (PII)。 如果您要使用 PII 来识别访客(例如电子邮件地址),我们建议您存储信息的哈希版本或加密版本。 ECID 库支持对用户标识符进行哈希处理。 请参阅对 setCustomerIDs 的 SHA256 哈希处理支持。
// Single ID with a single authentication state
visitor.setCustomerIDs({
"userid":{
"id":"67312378756723456",
"authState":Visitor.AuthState.AUTHENTICATED
}
});
/*
Multiple IDs with only the first ID explicitly assigned an authentication state.
The second ID is not explicitly assigned an authentication state and is implicitly
assigned Visitor.AuthState.Unknown by default.
*/
visitor.setCustomerIDs({
"userid":{
"id":"67312378756723456",
"authState":Visitor.AuthState.AUTHENTICATED
},
"dpuuid":"550e8400-e29b-41d4-a716-446655440000"
});
// Multiple IDs with identical authentication states
visitor.setCustomerIDs({
"userid":{
"id":"67312378756723456",
"authState":Visitor.AuthState.AUTHENTICATED
},
"dpuuid":{
"id":"550e8400-e29b-41d4-a716-446655440000",
"authState":Visitor.AuthState.AUTHENTICATED
}
});
// Multiple IDs with different authentication states
visitor.setCustomerIDs({
"userid":{
"id":"67312378756723456",
"authState":Visitor.AuthState.AUTHENTICATED
},
"dpuuid":{
"id":"550e8400-e29b-41d4-a716-446655440000",
"authState":Visitor.AuthState.LOGGED_OUT
}
});
返回客户 ID 和身份验证状态 section-71a610546188478fa9a3185a01d6e83b
使用 getCustomerIDs 可返回客户 ID 和相关的身份验证状态。 此方法会作为整数返回访客的身份验证状态。
语法
getCustomerIDs 通过以下语法返回数据。
{
[customerIDType1]:{
"id":[customerID1],
"authState":[authState1]
},
[customerIDType2]:{
"id":[customerID2],
"authState":[authState2]
}
...
}
示例
返回的客户 ID 和身份验证状态数据应类似于以下示例。
Object customerIDs = visitor.getCustomerIDs();
// No setCustomerIDs call on this instance
{}
// setCustomerIDs call on this instance with {"userid":{"id":"67312378756723456"}}
{
"userid":{
"id":"67312378756723456",
"authState":0
}
}
// setCustomerIDs call on this instance with {"userid":{"id":"67312378756723456","authState":Visitor.AuthState.AUTHENTICATED}}
{
"userid":{
"id":"67312378756723456",
"authState":1
}
}
// setCustomerIDs call on this instance with {"userid":{"authState":Visitor.AuthState.LOGGED_OUT}}
{
"userid":{
"authState":2
}
}
// setCustomerIDs call on this instance with {"userid":{"authState":Visitor.AuthState.LOGGED_OUT},"dpuuid":{"id":"550e8400-e29b-41d4-a716-446655440000"}}
{
"userid":{
"authState":2
},
"dpuuid":{
"id":"550e8400-e29b-41d4-a716-446655440000",
"authState":0
}
}
SDK 支持 section-861c6b3b1ba645dda133dccb22ec7bb0
访客ID服务支持在我们的Android和iOS SDK代码中使用客户ID和身份验证状态。 请参阅以下代码库:
面向 Analytics 和 Audience Manager 客户的注意事项 section-3a8e9d51e71c4c6e865184b81ed9d99b
如果您将声明的ID传递到Audience Manager,userid对象需要匹配与数据源关联的集成代码。 有关详细信息,请参阅配置合并规则代码文档中的Visitor ID Service部分。
recommendation-more-help
id-service-help