private void SetCampaignTrackingCookie(string email, string recipientListId)
        {
            // Use the cookie helper to drop the Campaign tracking cookie
            var datasourceId   = _campaignConnector.GetDataSources().First().Id.ToString();
            var trackingCookie = _cookieHelper.GetTrackingCookie(_campaignConnector.Id.ToString(),
                                                                 _campaignConnector.InstanceId.ToString());
            var data = trackingCookie.FirstOrDefault(cd => cd.DatasourceId == datasourceId);

            if (data != null)
            {
                data.EntityId     = email;
                data.DatasourceId = recipientListId;
            }
            else
            {
                var item = new CookieData
                {
                    DatasourceId = recipientListId,
                    EntityId     = email
                };
                trackingCookie.Add(item);
            }
            _cookieHelper.UpsertTrackingCookie(
                _campaignConnector.Id.ToString(),
                _campaignConnector.InstanceId.ToString(),
                trackingCookie);
        }
Exemplo n.º 2
0
        private string GetEmail <TPayload>(TrackingData <TPayload> trackingData)
        {
            var connectorId = EPiServer.ConnectForCampaign.Core.Helpers.Constants.ConnectorId.ToString();
            var instanceId  = EPiServer.ConnectForCampaign.Core.Helpers.Constants.DefaultConnectorInstanceId.ToString();
            var email       = _cookieHelper.GetTrackingCookie(connectorId, instanceId).FirstOrDefault()?.EntityId;

            if (string.IsNullOrEmpty(email))
            {
                email = trackingData?.User?.Email;
            }

            return(email);
        }