I followed this community post on how to programmatically trigger goals, and it works as advertised:
Sitecore.Data.Items.Item goalItem = Sitecore.Context.Database.GetItem(goalId); var goalTrigger = Tracker.MarketingDefinitions.Goals[goalItem.ID]; var goalEventData = Tracker.Current.CurrentPage.RegisterGoal(goalTrigger); goalEventData.Data = goalItem["Name"]; goalEventData.ItemId = goalItem.ID.ToGuid(); goalEventData.DataKey = goalItem.Paths.Path; goalEventData.Text = "Goal for Logic"; Tracker.Current.Interaction.AcceptModifications();
This single line of code seems to break the goal triggering. When the code is present, the triggering code is run, and the goal apparently triggered, but the goal never shows up in Experience Profile. If I remove that line, the goal shows up as expected in Experience Profile again.
We have previously used the
Cancel() method with great success, but after the switch to Sitecore 9.x it stopped the goal from being registered properly.
I suspected it might have something to do with session timeouts and set
<sessionState timeout="2"> in Web.config. I then waited for about 30 minutes, yet still nothing appeared in Experience Profile.
So the question is then: How can we programmatically trigger goals and have the API URL not show up in Path Analyzer?
Sitecore 9.1.0 (rev. 001564)