Showing posts with label ExM. Show all posts
Showing posts with label ExM. Show all posts

Tuesday, July 19, 2016

Sitecore ExM in Depth: How Sitecore Email Experience Manager Determine If Message Was Opened

When you look at source of html email message that was delivered by Sitecore Email Experience Manager you see strange image tag that is located before closing BODY and HTML tags:

<img height="1" width="1" border="0" style="border-color: transparent;" src="http://your.host/sitecore/RegisterEmailOpened.aspx?ec_contact_id=3D0A4C096C4287C4C50A33E8BB5DB87E04&ec_message_id=3D16BE08364227=4836B57FB8CDCEB15C85" />

It is service ExM tag that is inserted to all email. This image tag has source property link to service ExM page: RegisterEmailOpened.aspx. And as parameters are transferred IDs of contact and email. When your mail agent(or browser) tries to load this image it sends request to Sitecore server and triggers event about email opening. Of course it will not work for all mail clients and web mail portals, but it is still good way to get more information about behavior of email recipients. (One of reasons could be not downloading images by default. It is frequent setting for mobile mail agents.)


Sitecore ExM in Depth: Hard and Soft Bounce Detection Facts


There are few facts about soft and hard bounce detection that are not obvious and need your attention,when you try to get messages appeared in "Hard Bounce" or "Soft Bounce" engagement analytics states:
  • ExM version is up to 3.2.1 bounce detection works only when messages delivery is performed via Sitecore AppCenter. Setting UseLocalMTA determine if Sitecore MTA(mail transfer agent) should be used. When setting UseLocalMTA is equal true and your  then you will not be able to get hard and soft bounce messages states.
  • Starting from Sitecore Email Experience Manager 3.3 you are able to detect bounces with your local MTA. 
  • Bounce detection is performed by scheduled task: /sitecore/system/Modules/E-mail Campaign Manager/Instance Tasks/Content Management Primary/Check Bounced Messages. Default interval between running of task is 12 hours 30 minutes. Be patient: contacts will not appear immediately in  hard and soft bounce states.
  • Easiest way to check if latest bounce detection was success is to check Items field of Check Bounced Messages scheduled task. It should contain time stamp of latest success bounce detection. If  latest bounce detection was failed this field will contain "1/1/0001 12:00:00 AM" or empty string.
  • Bounce detection is performed via request to Sitecore App Center service.

Friday, May 27, 2016

Sitecore EXM: The remote name could not be resolved: 'default-cd-cluster'

While configuring sending EXM messages on Sitecore I faced with problem. Some emails were delivered, others not. Sitecore Email Experience Manager log reported next error:

ERROR Failed to enroll a contact in the engagement plan.
Exception: System.Net.WebException
Message: The remote name could not be resolved: 'default-cd-cluster'
Source: System
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadString(Uri address)
   at Sitecore.Modules.EmailCampaign.Core.Gateways.DefaultAnalyticsGateway.EnrollOrUpdateContact(Guid contactId, Guid planId, Guid automationStateId, EcmCustomValues customValues, String[] validStates)
   at Sitecore.Modules.EmailCampaign.Core.Analytics.AutomationStatesManager.EnrollOrUpdateContact(Guid contactId, Guid planId, String stateName, EcmCustomValues customValues, String[] validStates)
   at Sitecore.Modules.EmailCampaign.Core.Dispatch.DispatchManager.EnrollOrUpdateContact(Guid contactId, DispatchQueueItem dispatchQueueItem, Guid planId, String stateName, EcmCustomValues customValues)
   at Sitecore.Modules.EmailCampaign.Core.Dispatch.DispatchTask.OnSendToNextRecipient()

After search this error message I found two articles (first, second) that say the same: you should change Analytics.ClusterName setting. And this solution really helps. This setting is located in Sitecore.Analytics.Tracking.config file and EXM uses it to access to /sitecore/AutomationStates.ashx handler to change contact state in engagement plan.

But, doesn't sound strange? That you should to configure something to start work with Sitecore single instance. How about installation CM/CD/Analytics on one server? Or how about development and testing environments? I know that there are a lot of places where Sitecore as web application requires host name, but everywhere it works automatically. You shouldn't configure something additionally. That's why I decided to customize Sitecore to use 'default-cd-cluster' as key that will be replaced in EXM with current host name. And it was quite easy:

public class CustomAnalyticsGateway : DefaultAnalyticsGateway
{
    public override ContactLockingStatus TryGetContactForUpdate(ID contactId, 
            LeaseOwner leaseOwner, 
            System.TimeSpan leaseDuration, 
            System.TimeSpan timeout, 
            out Sitecore.Analytics.Tracking.Contact contact, 
            out string webClusterName)
    {
       var r = base.TryGetContactForUpdate(contactId, leaseOwner, leaseDuration, timeout, out contact,
           out webClusterName);
       if (webClusterName!= null && webClusterName.Contains("default-cd-cluster"))
       {
           webClusterName = System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteName();
       }
       return r;
    }
}

If webClsterName contains 'default-cd-cluster' we change it with current sitename(it also will work if we will replace it with null due to Sitecore EXM later fill it with another value if it is null). And you should let EXM know to use this gateway in your configuration:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <gatewayFactory>
      <analyticsGateway type="YourSolution.CustomAnalyticsGateway, YourSolution"/>
    </gatewayFactory>
  </sitecore>
</configuration>

With this custom class and configuration Email Experience Manager started to work on all machines. And you should not change 'default-cd-cluster' with host name in all your solutions. But don't forget to change this setting when going to live environment.