An introductory series on marketing category subscriptions in Sitecore

16.10.2019
Reading time: 4 min

Dirk Schäfauer is Sitecore Senior Solution Architect at mmmake – so he knows his way around Sitecore. In his series of articles, he looks at various ways of using Sitecore as a marketing tool. Today: using the potential of the EXM preference center for the opposite purpose – signing up for marketing categories such as newsletters.

The topic could therefore be called EXM Newsletter Subscription or something similar. Rather, it is a forms extension where you only register for marketing categories.

These marketing categories are based on Sitecore’s rules engine, so I don’t want to classify them as EXM-specific, they can also be used for marketing automation or personalization.

But let’s not get too far ahead of ourselves: Sitecore 9.1 introduced the Marketing Preference Center, a really cool way to manage marketing category subscriptions. However, the settings center is even more useful as it can be configured per manager master, so it is suitable for multiple locations and can look different for each location. You can also implement your own Javascript logic there!

The only question that arises here is: if Sitecore offers something great for unsubscribing from newsletters (or categories), why isn’t there a great equivalent for subscribing to those categories? The Preference Center is currently only available if you have already received a newsletter (e.g. Email Campaign Sample Newsletter). But what if I want to register for a marketing category?

Steve McGill on the Preference Center in EXM and the complexity of Subscription Management:

E-mail preference center

The release of Sitecore 9.1 introduces the much needed additional layer of preferences when it comes to determining who an email should be sent to. These preferences are designed in such a way that they are visible to the customer. Sitecore delivers a very simple UI that can be easily customized to your own brand. (By the way, a REST API is used, so you can easily transfer the sample code into your own JSS/MVC component if you wish).

Or Pete Navarra, who sums it up in Introduction to Email Experience Manager:

Subscription management in EXM is provided as a fully functional API and is expected to be implemented according to the customer’s wishes. So many business requirements can differ between implementations that it would be inadequate to build something off the shelf – or that some changes would always be required. Instead, the path Sitecore has taken is to provide all the required endpoints and hooks and allow the customer to implement subscription management as he/she sees fit.

The use case or: How did I get into this situation?

We had a difficult request from our customer: They wanted to send newsletters from their own CRM via EXM. In principle, this should not be a problem. But adding contacts to contact lists was always incorrect. In most cases, the lists were not fully indexed, which resulted in the newsletter not being sent completely.

So what if you want exactly what the Preference Center can do? Unfortunately, there is nothing that is not included in the packaging.

There is a cool SubscriptionManager that calls a SubscribeEvent pipeline. The pipeline looks as follows by default:

<SubscribeEvent patch:source="Sitecore.EmailExperience.ContentManagementPrimary.config"/>

Um, cool, it’s empty! The “UnsubscribeFromList” pipeline is already filled with more life:

<UnsubscribeFromList patch:source="Sitecore.EmailExperience.ContentManagementPrimary.config">
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.GetList, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.CheckDefaultExcludeCollection, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.CheckSegmentedList, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.CheckSubscription, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.UnsubscribeContact, Sitecore.EmailCampaign.Cm" resolve="true"/>
<processor type="Sitecore.EmailCampaign.Cm.Pipelines.UnsubscribeFromList.SendNotification, Sitecore.EmailCampaign.Cm" resolve="true"/>
</UnsubscribeFromList>

Is that what I want to achieve? NO.
I no longer wish to subscribe to or unsubscribe from any lists!
We want to do it the cool way!

In the following series of blog posts, I will show you how you can use the marketing categories specifically for EXM. The idea behind it is pretty simple: make it like the Preference Center that was introduced in Sitecore 9.1, and I use Sitecore Forms to handle it all. The form itself has many surprises: it replaces the Preference Center, which is no longer accessible if you delete the newsletter you have already received.

The first idea was to subscribe to the contacts using the public method of the SubscriptionManager:

    public virtual bool Subscribe(
      ContactIdentifier contactIdentifier,
      Guid messageId,
      bool subscriptionConfirmation)

But I don’t want to register a contact for a message. The private method that Sitecore uses inside is more reliable for me:

    private bool Subscribe(
      Contact contact,
      Guid recipientListId,
      ManagerRoot managerRoot,
      bool subscriptionConfirmation)

This is exactly what I needed! But it’s private. And this is where the real journey begins.

Read more in the following blog posts:
Part 1 – The concept
Part 2 – Custom field to retrieve marketing preferences and contact list
Part 3 – Submitting the custom marketing preference action
Part 4 – User-defined field for identifying contacts
Part 5 – The “magic” subscription form
Part 6 – Segmented lists


That sounds like a big task! But join me on this journey and you won’t regret it!

You can find the source code here: https://github.com/monkey-dsc/Feature.SitecoreForms.MarketingCategoriesSubscription/

Read the next part: Part 1 – The concept

The author
Software developer
Dirk
Schäfauer
Dirk is a software developer at mmmake and an absolute Sitecore expert.
Contact
mmmake-autor-dirk-schaefauer