Sitecore 7.5 DMS 以编程方式跟踪目标

Sitecore 7.5 DMS Tracking Goal Programmatically

我目前正在尝试使用 sitecore DMS 跟踪 sitecore 7.5 中的按钮点击,我在互联网上找到了很多信息,但其中大部分是在切换到 MongoDB 之前的 7.5 之前的信息。 ..

以前看起来像这样:

//Check that analytics are on...
if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.CurrentPage != null)
{
  //Get the item goal.
  Item goalItem = Sitecore.Context.Database.GetItem("{xxxxx-xxx-xxx-xxxxx}");
  //Page event wrapper
  PageEventItem goal = new PageEventItem(goalItem);
  //Create the record that needs to  store the goal
   VisitorDataSet.PageEventsRow pageEventsRw = Sitecore.Analytics.Tracker.CurrentPage.Register(goal);
  //this is not mandatory
  pageEventsRw.Data = "custom text";
  Sitecore.Analytics.Tracker.Submit();
}

我想在 Sitecore 7.5 中实现这种目标,但很难在互联网上找到很多资源,想知道是否有高级 sitecore 用户可以为我指明正确的方向?

干杯, 兆瓦

你能试试吗:

if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.Current.CurrentPage != null)
  {
      Sitecore.Data.Items.Item GoaltoTrigger = Sitecore.Context.Database.GetItem("{Item ID of the Goal}");
      if (GoaltoTrigger != null)
      {
          Sitecore.Analytics.Data.Items.PageEventItem registerthegoal = new Sitecore.Analytics.Data.Items.PageEventItem(GoaltoTrigger);
          Sitecore.Analytics.Model.PageEventData eventData = Sitecore.Analytics.Tracker.Current.CurrentPage.Register(registerthegoal);
          eventData.Data = GoaltoTrigger["Description"];
         Sitecore.Analytics.Tracker.Current.Interaction.AcceptModifications();
      }
  }