Skip to content

Instantly share code, notes, and snippets.

@islaytitans
Created May 30, 2016 14:06
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 islaytitans/eab737aefa03dd334167cabe0f89c2fc to your computer and use it in GitHub Desktop.
Save islaytitans/eab737aefa03dd334167cabe0f89c2fc to your computer and use it in GitHub Desktop.
Controller to receive data and register Sitecore goals
public class PageEventController : Controller
{
[System.Web.Mvc.HttpPost]
public JsonResult RegisterGoal(string goalId, string goalDescription)
{
Item eventItem = Sitecore.Context.Database.GetItem(goalId);
var goal = new PageEventItem(eventItem);
if (!Tracker.IsActive)
Tracker.StartTracking();
Sitecore.Analytics.Model.PageEventData eventData = Tracker.Current.CurrentPage.Register(goal);
eventData.Data = goal["Description"] + " " + goalDescription;
Tracker.Current.Interaction.AcceptModifications();
return Json(new PageEventRequestResult()
{
Success = true,
Message = "Successfully registered goal",
});
}
}
@abhaydhar
Copy link

Jonathan- Can you please tell me which dll holds this class -PageEventRequestResult

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment