2

Created a Sitecore 9 form on which activates an EXM with a link redirecting to site's page. During form submission I am saving the contact. How do I track the same contact after clicking the link inside the email?

2

Each link in the email is rewritten to the url /sitecore%20modules/Web/EXM/RedirectUrlPage.aspx and the contact identifier is encrypted and added to the url in the ec_eq parameter. This means that as each user clicks the link, when the make it to the Sitecore site they are identified as the user the email was sent to. From that point forward, the user is known.

I think the answer to your question is that it is already done in EXM.

1

Depends on the version of Sitecore. In earlier versions of Sitecore 9 (9.0.X and 9.1), Sitecore Forms did not have a built-in way of associating the contact filling out the form and creating a known contact. Many solutions needed to create a custom submit action in order to fully Identify the contact filing out the form prior to sending an Email Campaign through the Sitecore Forms Submit Action.

It wasn't until Sitecore 9.2 when Sitecore updated the Send Email Campaign submit action to include fields to identify the user as shown below: enter image description here

Prior to Sitecore 9.2, if you needed to Identify the user, you had to create a custom submit action and do the Identification yourself. The snippet of code is below, but here is a larger example of creating a submit action for Sitecore Forms.

    protected override bool Execute(UpdateContactData data, FormSubmitContext formSubmitContext)
    {
        Assert.ArgumentNotNull(data, nameof(data));
        Assert.ArgumentNotNull(formSubmitContext, nameof(formSubmitContext));

        var firstNameField = GetFieldById(data.FirstNameFieldId, formSubmitContext.Fields);
        var lastNameField = GetFieldById(data.LastNameFieldId, formSubmitContext.Fields);
        var emailField = GetFieldById(data.EmailFieldId, formSubmitContext.Fields);

        if (firstNameField == null && lastNameField == null && emailField == null)
            return false;

        using (var client = CreateClient())
        {
            try
            {
                var emailIdent = new IdentifiedContactReference("IdentifiedEmail", GetValue(emailField));

                //Identify with Email
                CurrentTracker.Session.IdentifyAs(emailIdent.Source, emailIdent.Identifier);

                var expandOptions = new ContactExpandOptions(
                    CollectionModel.FacetKeys.PersonalInformation,
                    CollectionModel.FacetKeys.EmailAddressList);
                var contact = client.Get(emailIdent, expandOptions);

                //Set Fields
                SetPersonalInformation(GetValue(firstNameField), GetValue(lastNameField), contact, client);
                SetEmail(GetValue(emailField), contact, client);

                client.Submit();

                return true;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message, ex);
                return false;
            }
        }
    }

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.