I am using Sitecore 9.3. After I run the EXM campaign.I go to the email and click to see online version.

I can get the ec_eq query string on this. Then I tried to dycrypt it but can't get contact information on this (ec_contact_id).

Here my code:

QueryStringEncryption.GetDefaultInstance().TryDecrypt(HttpContext.Current.Request.QueryString, out NameValueCollection result);

I need to get contact then modify some information for it. Any suggestion on this case?

  • 1
    Can you add more details regarding where you are trying to decrypt the querystring? If you take a look at sitecore.stackexchange.com/questions/23697/… the httpBeginRequest pipeline decrypts ec_eq and populates the EXMContext object. May 2, 2021 at 10:07
  • I created a custom <mvc.resultExecuted> pipeline. In this process, I get the param ec_eq then try to decrypt it with code above but the result after decrypt only see keys bellow: [0] "sc_itemid" [1] "sc_lang" [2] "sc_pd_view" [3] "ec_message_id" [4] "ex_id_s" [5] "ex_id_i" [6] "ec_lang" [7] "ec_tvi" [8] "ec_emailid" Can't see contact information. Pls let me know if you need more information. May 3, 2021 at 12:55

1 Answer 1


You can't get the contact ID, you can only get the identifier that was used to email the contact. Usually this contact is the Alias, Sitecore.XConnect.Constants.AliasIdentifierSource identifier.

In your layout/rendering, add these two lines.

 var source = ExmContext.ContactIdentifier.Source;
 var identifier = ExmContext.ContactIdentifier.Identifier;

That will get you the identifier used and the value. From there you can find the contact by identifier.

public ListSubscriberFacetModel GetContactByIdentifier(string source, string identifier)
    using (XConnectClient client = SitecoreXConnectClientConfiguration.GetClient())
            var facetsToGet = new List<string>

            var existingContact = GetContact(source, identifier, client, facetsToGet.ToArray());

            if (existingContact == null)
                return null;

            // You have the contact Id here
        catch (XdbExecutionException ex)
            this.errorService.LogError(ex, this);

    return null;

private Contact GetContact(string source, string identifier, XConnectClient client, string[] facets)
    var reference = new IdentifiedContactReference(source, identifier);

    var existingContact = client.Get(reference, new ContactExpandOptions(facets));

    return existingContact;

Your Answer

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

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