0

I need to do a simple newsletter form. This form should work like this:

  • User inputs an email and presses to the submit button
  • User recieves message on email with confirm link
  • After user clicks on the link his email is added to Recipient list

This form should be work with help EXM

I've created Triggered message in the EXM with link for subscription. And I wrote this code for the Submit button for trigger the Newsletter Goal

    [HttpPost]
    public ActionResult NewsletterSubscribe(NewsletterViewBag model)
    {

        var goal = Context.Database.GetItem(newsletterGoal);

        if (goal == null)
        {
            continue;
        }

        var registerGoal = new Sitecore.Analytics.Data.Items.PageEventItem(goal);

        var eventData = Tracker.Current.CurrentPage.Register(registerGoal);

        eventData.Data = goal[DateTime.Now.ToString(CultureInfo.InvariantCulture)];

        Tracker.Submit();

    }

How I can assign my triggered message to the newsletterGoal? Also I try manually send message this way:

 MessageItem message = Sitecore.Modules.EmailCampaign.Factory.GetMessage(new ID(messageId));
   Sitecore.Modules.EmailCampaign.AsyncSendingManager manager = new AsyncSendingManager(message);
   var contactId = ClientApi.GetAnonymousIdFromEmail(email);
   var recipientId = (RecipientId) new XdbContactId(contactId);
   manager.SendStandardMessage(recipientId);

And I see error in the log: The recipient 'xdb:857bbea1-1f18-4621-a798-178399cd0b54' does not exist. But Triggered Message haven't any recipient list

4

1 回答 1

1

目标不直接分配给消息。但是,您可以分配参与计划和活动。每条消息都有自己的参与计划来处理跟踪消息中的联系人操作。如果您创建一个触发目标的活动,您可以将其分配给消息,并且当他们收到消息时它将与联系人相关联。您还可以利用消息参与计划在联系继续通过这些状态时触发事件。

此外,您在记录联系人数据时遗漏了一些详细信息。查看 EXM 模块中包含的时事通讯注册控件。其中的重要部分是:

    protected virtual RecipientId RecipientId
    {
        get
        {
            RecipientId recipientId = null;

            var contactId = ContactId;

            if (contactId != (ID)null)
            {
                recipientId = new XdbContactId(contactId);
            }

            return recipientId;
        }
    }

    protected virtual ID ContactId
    {
        get
        {
            if (!Email.Visible || string.IsNullOrEmpty(Email.Text))
            {
                return new ID(Tracker.Current.Contact.ContactId);
            }

            var anonymousId = ClientApi.GetAnonymousIdFromEmail(Email.Text);

            return anonymousId.HasValue ? new ID(anonymousId.Value) : new ID(Tracker.Current.Contact.ContactId);
        }
    }

    protected virtual void UpdateEmailInXdb()
    {
        _recipientRepository.UpdateRecipientEmail(RecipientId, Email.Text);
    }

它将电子邮件地址直接写入 Mongo,而不是等待会话结束。在您的注册代码中包含此属性以及相关的 RecipientId 和 ContactId 属性。

一旦他们注册,您可以通过编程方式注册目标或将他们发送到可以注册目标的感谢页面(高级 - 跟踪),或发送消息并让其注册目标。或者为流程的每个步骤创建一个包含状态的参与计划(这是最好的方法)。

您还需要将收件人添加到通讯消息稍后可以使用的列表中。实际上,在我看来,示例订阅表单可以满足您的所有需求。

于 2016-05-16T20:49:59.270 回答