I am facing a weird issue in my project. I am triggering goal programmatic way for some pages based on some fulfilling custom conditions. I am using the Sitecore 9.1 initial release. Here is my code:

if (Tracker.IsActive && Tracker.Current.CurrentPage != null)
   var goalItem = Sitecore.Context.Database.GetItem(goalId);

   if (goalItem != null)
       var goalTrigger = Tracker.MarketingDefinitions.Goals[goalId.ToGuid()];
       if (goalTrigger == null) continue;

       var goalEventData = Tracker.Current.CurrentPage.RegisterGoal(goalTrigger);
       goalEventData.Data = goalItem["Name"];
       goalEventData.ItemId = goalItem.ID.ToGuid();
       goalEventData.DataKey = goalItem.Paths.Path;
       goalEventData.Text = goalItem["Name"];

The code snippet seems to work for almost all the pages, but I saw for some pages goals are not tracking. I tried to assign a goal from Analyze menu item from the top menu bar, yet no luck. I tested with IsLiveEvent checked/unchecked. The result is the same. I ended the session with Session.Abandoned(). Same no showing the goal. I think I checked all the log files for including marketing automation but nothing suspicious.

I have no idea what else I can check. This is so frustrating. Can someone give me any lead, please?

  • It seems that the goalTrigger is null on that particular page. Is it the same goal which is working on some pages? Commented Oct 15, 2019 at 12:45
  • @HishaamNamooya I checked. They appear in the experience profile of the current visitor.
    – Foysal
    Commented Oct 15, 2019 at 14:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.