我对 Sitecore Analytics 和用户个人资料 key 有疑问。我需要能够获取单个页面的配置文件 key 的分数。例如,如果我有一个名为“traveler”的个人资料键,该键在给定页面上的值为 1-10,那么我需要能够获取内容作者分配的该键的值。我发现通过使用以下内容:
Sitecore.Analytics.AnalyticsTracker.Current.Data.Profiles.GetProfile("Profile Name").GetProfileKeyValue("traveler")
我可以获得用户在整个 session 中累积的总分,但我似乎找不到一种方法来获取当前页面的分数。
任何人都可以提供的任何见解将不胜感激。谢谢。
最佳答案
我知道这篇文章相当旧,但为了将来的引用,Sitecore 中发生了很多变化。 我不知道这在 2010 年是否可行,但至少在 2013 年有 API 方法可以提取页面的 Tracking 值。
我绝不会建议手动解析 __Tracking 字段中的原始数据。
以下是如何使用 Sitecore Analytics API 读取角色配置文件的跟踪数据:
public static string ProfileValues(this Item item)
{
StringBuilder sb = new StringBuilder();
TrackingField trackingField = new TrackingField(item.Fields[Constants.Sitecore.FieldIDs.Tracking]);
ContentProfile profile = trackingField.Profiles.FirstOrDefault(profileData =>
profileData.Name.Equals("Persona") && profileData.IsSavedInField);
ContentProfileKeyData[] profileKeys = profile.Keys;
foreach (ContentProfileKeyData profileKey in profileKeys)
{
sb.AppendLine(string.Format("{0}:{1};", profileKey.Name, profileKey.Value));
}
return sb.ToString();
}
致以诚挚的问候 拉塞·拉什
关于sitecore - 获取 Sitecore 中单个页面的个人资料关键分数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3943186/