Sitecore 6.5 DMS - Registering a goal completion via the API

只谈情不闲聊 提交于 2019-12-22 18:37:50

问题


I want to register a goal/conversion on my Sitecore 6.5 site using the API rather than a 'thank-you' page.

I've seen this question about how to do it Sitecore OMS - achieving a goal on a form submission but the answer relates to the API prior to Sitecore 6.5 where it was overhauled quite significantly.

Has anyone done this? Or has this functionality been intentionally removed?


回答1:


Have you tried something like

protected void btnSubmit_Click(object sender, EventArgs e)
{
    if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.CurrentPage != null)
    {
        PageEventData eventData = new PageEventData("My Goal Name");
        eventData.Data = "this is some event data.";
        VisitorDataSet.PageEventsRow pageEventsRow = Sitecore.Analytics.Tracker.CurrentPage.Register(eventData);
        Sitecore.Analytics.Tracker.Submit();
    }
} 

That should register the goal on the currentpage, but not before you decide to in your code




回答2:


You can also use a modified version of the code which references the Goal Item by its GUID:

if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.CurrentPage != null)
{
PageEventItem goal = new PageEventItem(Sitecore.Context.Database.GetItem("GOALGUID"));
VisitorDataSet.PageEventsRow pageEventsRow = Sitecore.Analytics.Tracker.CurrentPage.Register(goal);
Sitecore.Analytics.Tracker.Submit();
}

Make sure you have deployed and published your goal and or goal category too as the code will fail otherwise.



来源:https://stackoverflow.com/questions/8976407/sitecore-6-5-dms-registering-a-goal-completion-via-the-api

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