Skip to content

Instantly share code, notes, and snippets.

@islaytitans
Last active May 30, 2016 14:30
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/c346c11576403bcd155ecfee041b5ab3 to your computer and use it in GitHub Desktop.
Save islaytitans/c346c11576403bcd155ecfee041b5ab3 to your computer and use it in GitHub Desktop.
Gets goals from the Sitecore xDB
public class GetGoals : ReportProcessorBase
{
private readonly QueryBuilder goalsQueryBuilder = new QueryBuilder()
{
collectionName = "Interactions",
QueryParms =
{
{
"ContactId", "@contactId"
},
{
"Pages.PageEvents.0", "{$exists:1}"
}
},
Fields =
{
"_id",
"ContactId",
"Pages_PageEvents_PageEventDefinitionId",
"Pages_PageEvents_DateTime",
"Pages_PageEvents_Data",
"Pages_Url_Path",
"Pages_Url_QueryString",
"Pages_PageEvents_Value",
"Pages_Item__id"
}
};
public override void Process(ReportProcessorArgs args)
{
DataTable goalsData = this.GetGoalsData(args.ReportParameters.ContactId);
args.QueryResult = goalsData;
}
private DataTable GetGoalsData(Guid contactId)
{
ReportDataProvider reportDataProvider = this.GetReportDataProvider();
Assert.IsNotNull((object)reportDataProvider, "provider should not be null");
return reportDataProvider.GetData("collection", new ReportDataQuery(this.goalsQueryBuilder.Build())
{
Parameters =
{
{
"@contactId", (object) contactId
}
}
}, new CachingPolicy()
{
NoCache = true
}).GetDataTable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment