2

How do you get the raw contact id from the ec_contact_id on the URL created by EXM?

We are using Sitecore's EXM to send emails containing links for surveys to recipients. When the recipient takes the survey we want to tie the response back to the recipient. Since EXM puts a unique Id, ec_contact_id, for the contact (encrypted) we want to use that to determine the recipient versus adding our own custom id.

We found this article, https://briancaos.wordpress.com/2015/04/27/sitecore-8-exm-get-the-email-recipient-from-a-sublayout/, and tried implementing it in the Sitecore controller that gets called when the recipient clicks on the link but the resulting recipient name comes back as empty. We don't have a "sc_item_id" value so we tried "_id" and "ec_message_id" in its place but neither value produced a valid contact Id or recipient name. We also tried looking in MongoDB with the decrypted contactId but couldn't find a match.

4

2 回答 2

1

你可以尝试这样的事情:

//get value of the ec_contact_id parameter for current request
string queryString = WebUtil.GetQueryString( Sitecore.Modules.EmailCampaign.GlobalSettings.AnalyticsContactIdQueryKey); 

var shortID =  ShortID.TryParse(queryString, out shortID);

System.Guid contactId;

// where initializationVector is System.Guid of your email message item.
using (var cryptoServiceProvider = new GuidCryptoServiceProvider(System.Text.Encoding.UTF8.GetBytes(GlobalSettings.PrivateKey), initializationVector.ToByteArray())) 
{
       contactId = cryptoServiceProvider.Decrypt(shortID.Guid);
}
于 2016-04-27T14:18:53.313 回答
0

当您在电子邮件列表中创建新用户时,Sitecore 会在 xDB Mongo 数据库中创建一条记录。您应该能够从用户个人资料中获取电子邮件地址。

Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Entries[Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Preferred]

Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Entries["work_email"]
于 2016-11-16T05:23:00.113 回答