7

How can I get a user's persona information in code when I am requesting the information not as the user but as someone else, e.g. a site administrator??

I have looked at how the Best Pattern match works in the Experience Profile but this process is very complicated, uses a crazy number of pipelines and does not provide a simple method to hook into.

Has anyone done something like this before?

Using Sitecore 8.1, ideally I would like to retrieve that values stored against the user. Not to worried about the best pattern/profile matched but you can get extra points for suggesting a solution to this.

  • 1) What Sitecore version are you on? 2) Do you need to get the best matching persona? Or the best matching pattern card? – Dmytro Shevchenko Apr 4 '17 at 11:52
  • more info added to question – Michael Edwards Apr 4 '17 at 14:15
2

You can retrieve contact's behavioural information with the help of ContactRepository which is the recommended way to work with contact data in the situation you described (requesting information as not the website user).

    var repository = Factory.CreateObject("tracking/contactRepository", true) as ContactRepositoryBase;
    var contact = repository.LoadContactReadOnly(ID.NewID);

    foreach (IBehaviorProfileContext behaviorProfile in contact.BehaviorProfiles.Profiles)
    {
        var profileScores = behaviorProfile.Scores;
        ID patternId = behaviorProfile.PatternId;
        //and other properties                
    }

It returns contact data from xDB (MongoDB). Data representation in Contacts collection:

enter image description here

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.