LibrarySites.Banner

Creating a Custom Report on SXP v8.2

Creating a Custom Report for trending Operating System used on the website. Using SXP v8.2 Update 2 as my instance.

  1. Write a custom Dimension that collects data about the Operating System data from Analytics such as the name and major version. Similar to the code below. Compile and deploy this to your Sitecore instance

 

Filename: ByOperatingSystem.cs

using Sitecore.Analytics.Aggregation.Data.Model;

namespace MyDimension

{

    class ByOperatingSystem : VisitDimensionBase

    {

        public ByOperatingSystem(Guid dimensionId)

            : base (dimensionId)

        {

        }

 

        public override string GetKey(IVisitAggregationContext context)

        {

            var osData = context.Visit.OperatingSystem;

            return string.Format("{0}", osData.Name);

        }

 

        public override bool HasDimensionKey(IVisitAggregationContext context)

        {

            var osData = context.Visit.OperatingSystem;

            return osData != null &&

                !string.IsNullOrEmpty(osData.Name);

        }

    }

}

  1. Create a new Dimension under ‘/sitecore/system/Marketing Control Panel/Experience Analytics/Dimensions/Visit’s and call it ‘By OS Version’. This will create a Dimension item with a default child Segment called ‘All’.
  2. Rename ‘All’ to ‘All Visits By OS Version’ to give more description to the Segment since we will be using this later when creating the Report.

 

Figure 1. Dimension and Segment

 

  1. Deploy the ‘All Visits By OS Version’ Segment by selecting the item and clicking the green Deploy button under the Review menu.

Figure 2. Deploy Segment

 

  1. Take note of the Item ID for the Dimension and the Segment, you can find this information on the ‘Quick Info’ of the selected item.

 

Figure 3. Dimension Item ID

 

Figure 4. Segment Item IDtset

     6. Deploy the DLL of the code earlier to the ‘\bin’ folder of your instance then using the Dimension ID register the new Dimension in the ‘..Website\App_Config\Include\ExperienceAnalytics\Sitecore.ExperienceAnalytics.Aggregation.config’

Figure 5. Changes to the config file to register a custom Dimension

7. Let’s create a new Report by duplicate an existing one. For this example, lets duplicate the ‘Overview’ report in the Experience Analytics found here ‘/sitecore/client/Applications/ExperienceAnalytics/Dashboard/Audience/Overview’ in the Core database. Let’s give it a name ‘OS’.

Figure 6. Duplicating the ‘Overview’ report

    8. This will copy the item including its children.

 

Figure 7. The ‘OS’ report and its inherited children

    9. For simplicity, lets remove the other items that we don’t need for this report and keep the ‘ExperienceAnalytics Stylesheet’ and ‘All visits’ items.

Figure 8. ‘OS’ item with its child items.

 10. Let’s remove the corresponding controls associated with the items that we have delete in the previous steps. Select the ‘OS’ report that we have created then open the Presentation Detail and go to the Control tab.

Figure 9. Control’s for the ‘OS’ report

 

    11. Scroll down and navigate to the ‘ColumnPanel*Content’ placeholders and remove the following Controls below them save the changes.

  1. ColumnPanel 2.1 Content
  2. ColumnPanel 2.2 Content
  3. ColumnPanel 3.1 Content
  4. ColumnPanel 3.2 Content

    12. Select ‘ColumnPanel 1.1 Content’ and changes its ‘Data Source’ to point to ‘/sitecore/client/Applications/ExperienceAnalytics/Dashboard/Audience/OS/PageSettings/All visits’

    13. Select the ‘All visit’ child of the ‘OS’ report as we have to change the settings for a couple of fields.

    14. Let’s update the ‘Metrics’ field under the ‘Data’ section and remove ‘Value per Visit’ and keep ‘Visit’.

Figure 10. Metric field changes

  15. On the ‘Segment’ field (still under the ‘Data’ section, lets point it to the Segment that we have created and deployed earlier.

 

Figure 11. Segment field changes

   16. Let’s clear the values for the following fields ‘Keys’ and ‘KeyGrouping’.

Figure 12. Changes to the ‘Key’s and ‘KeyGrouping’ fields

   17. Save the changes to the item.

   18. Go to ‘Launch Pad’ then open up ‘Experience Analytics’ and you should see your new Report on the left navigation, clicking on it should display the bar graph with the trending OS data.

Figure 13. New report in the Dashboard by OS.