我知道这篇文章相当陈旧,但为了将来的参考,Sitecore 已经发生了很大变化。我不知道这在 2010 年是否可行,但至少在 2013 年有用于提取页面跟踪值的 API 方法。
我绝不建议手动解析 __Tracking 字段中的原始数据。
以下是使用 Sitecore Analytics API 读取 Persona Profile 跟踪数据的方法:
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();
}
最好的问候 Lasse Rasch