2

我目前正在尝试使用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 用户可以为我指明正确的方向?

干杯,兆瓦

4

1 回答 1

2

你能试一下吗 :

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();
      }
  }
于 2015-11-13T10:23:39.850 回答