Thursday, 16 February 2017

Build Custom Analytics Report - Part 2 – Storing and Retrieving Data


In part 1 of this blog posts series I discussed the business needs for building a custom analytics report, In this part I will show you how you can save your analytics data to MongoDB using the analytics tracker, then how you can aggregate this data into reporting SQL server database, in future blogs posts will show you how we can build SPEAK application to display the data and how you can extend the analytics filters based on your report needs




If you missed part 1 you can check it here.

First thing you need to do is to create a sitecore goal item for each button you want to track, this goal will be triggered when a site visitor click on the required element, as you can see from the following screen shot:

The following script will andadd a click event to the required element (button, anchor…etc.), and as you can see from the following snippet an ajax call will fire to call a backend method called “RegisterGoal”.


The following code snippet is the back-end controller method that will be called and as you can see I get all the information needed to be saved, as you see I used the analytics tracker that help you to identify and track contacts so you can see all site contacts activities on your website, You can use this information gathered by tracking contacts during current and past web sessions for personalization, reporting and optimizing your website.

More information can found here.

 

If you execute the above code you will get the following result in the interaction collection in the analytics MongoDB:



Now you need to move the data from the interactions in the analytics collection to the reporting SQL database and to do that you need to configure an aggregation processor which will be triggered when rebuilding the reporting database, detailed information about rebuilding the reporting database can be found here


Following is the code needed for this:


Following is the configuration to add your custom processor to the analytics aggregation:




One last thing, you need to create a fact table in the reporting database, in this table that data will be aggregated from the MongoDB by the aggregation process, following is the script that you can use to create the table:





Now you have the data ready to be display in your SPEAK report! SPEAK report is the next step!


 

2 comments:

Unknown said...

How can I write to more than one fact tables https://sitecoreinfo.blogspot.com/logout?d=https://www.blogger.com/logout-redirect.g?blogID%3D491530016688261497%26postID%3D33090616675485720

sri said...

Thanks for sharing this.,
Leanpitch provides online training in CSPO during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSPO Certification Workshop in different cities.


Product owner certification

Post a Comment