Sitecore OMS - achieving a goal on a form submission

强颜欢笑 提交于 2019-12-04 15:33:37

You have several possibilities:

  1. Most forms have a confirmation page, when everything is submitted and approved. You can attach an event to this page through the normal user interface. There are no special code required for this and it is out of the box.

  2. As you say you can do it by code. This is fairly easy and should look something like this:

    public void RegisterEvent(){ if (!AnalyticsTracker.IsActive) return;

    AnalyticsTracker tracker = AnalyticsTracker.Current;

    if (tracker == null || tracker.CurrentPage == null) return;

    AnalyticsPageEvent pageEvent = new AnalyticsPageEvent() { Name = "TheNameOfYourEvent", Key = "TheKeyOfTheEvent", Text = "SomeText", Data = "Event data can contain all the entered information if you like", };

    tracker.CurrentPage.TriggerEvent(pageEvent); tracker.Submit(); }

Whether you hardcode the event or you make it variable depends on whether you need to change the event frequent.

The first option is the most simple, but if you also want to integrate to a CRM and store user input, you might want to go with option 2 as you can store the profile data as well.

Hope that helps!

Yes, you can set the goal as achieved using the AnalyticsTracker.TriggerEvent method at the appropriate point in your form's workflow. Putting the name of the goal as a template parameter is a great idea. Even better, use a droplink and point the source at /sitecore/system/Marketing Center/Goals/.

EDIT

See the Analytics Configuration Reference on how to programmatically "Register an Analytics Page Event."

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!