Is there an option to switch Contact context programmatically?

Let's say i have some logic that depends on Contact context. When running such logic i would want to use something like

using (new Sitecore....ContactSwitcher("contactID"))
    //my logic with rules and personalization

I.e. Something EXM does with &recipient=xdb:{contactID} parameter

1 Answer 1


Doesn't exist a ContactSwitcher like LanguageSwitcher or UserSwitcher.

You need to identify new user when you want to switch to other contact.

            var contactIdentifier = "contactemail or otheridentifier"; 
            if (Tracker.Current.Contact != null && Tracker.Current.Contact.Identifiers.Identifier == contactIdentifier)
                // Contact already identified

If you want to switch back to previous user you need to identify again previous contact.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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