Skip to content

Instantly share code, notes, and snippets.

@BenGGolden
Created November 27, 2016 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenGGolden/1f21431c35388b2d3b95726393305b56 to your computer and use it in GitHub Desktop.
Save BenGGolden/1f21431c35388b2d3b95726393305b56 to your computer and use it in GitHub Desktop.
Sitecore rule engine action to register a goal
public class RegisterGoalAction<T> : RuleAction<T> where T : RuleContext
{
public ID GoalId { get; set; }
public override void Apply(T ruleContext)
{
if (!Tracker.IsActive || Tracker.Current.CurrentPage == null) return;
var goal = (PageEventItem)Context.Database.GetItem(GoalId);
if (goal != null)
{
Tracker.Current.CurrentPage.Register(goal);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment