Create a custom personalization token
In the Email Experience Manager (EXM), you can use tokens to personalize your email campaign messages. For example, at the beginning of a message, you can use the token $name$ in the greeting so that when you send your email campaign, the token is replaced with the name of the contact.
If you want to use tokens that are not available by default, you can create a custom token that you can use for your email campaigns.
For custom tokens to be replaced in the online Preview mode, you must extend the getContact pipeline.
To create a custom token, you must:
Create a custom contact facet
In the Sitecore Experience Database, you can extend the contact with your own custom data by creating a new custom contact facet.
Create a custom dispatch task
Create a custom dispatch task
To load custom facets that you just created, you must:
-
Override the default dispatch task in the
Sitecore.EmailExperience.ContentManagement.configfile.For example:
-
In exm/dispatchTask, in the
App_Config\Sitecore\EmailExperience\Sitecore.EmailExperience.ContentManagement.configfile, replace the default dispatch task with your custom dispatchTask.For example:
When you preview the email message for a specific recipient, custom tokens implemented using the CustomDispatchTask are not visible. Instead, use the Send a quick test feature on the Review tab.
Override the default token map
Override the default token map
You must override the default implementation of the recipientPropertyTokenMap token map class that describes the bindings between tokens and properties of a contact.
To override the recipientPropertyTokenMap token map class and bind the token key to a property on your custom facet:
-
Replace or patch the
recipients/recipientPropertyTokenMapelement inApp_Config\Sitecore\EmailExperience\Sitecore.EmailExperience.Core.configfile with your custom token map.For example:
-
Create your custom token map by adding your custom token.
For example:
You can now use the $customtokenkey$ token in email messages and it will be replaced with the value that is stored on your custom facet for the relevant contact.
If you want to import the new custom facet from a file, you can extend the import contacts wizard to include the custom contact facet as a new mapping field.