Skip to Content
Technical Articles

Tracking Portal site & App usage via SAP Web Analytics in SAP Cloud Platform

One of the most frequently asked question from customers developing apps on SAP Cloud Platform is “How do I know which apps are being frequently used”. There are several application/traffic monitoring tools available in the market which can help in answering the questions like:

  • Which apps are heavily used
  • How do users navigate to a particular app
  • Page visits
  • Devices details like OS/browser along with Geo-locations
  • Number of unique users
  • Bounce rate

The good news is that we now have a service on SAP Cloud Platform called “SAP Web Analytics” which is offered as a SaaS solutions for customers to subscribe to. This service is being tightly integrated into existing SAP solutions like SAP Jam, SuccessFactors etc. Customers can subscribe to this service and also track the usage of portal sites along with the individual elements within a SAPUI5 based Fiori apps.

In this blog post, I will walk through the steps to setup SAP Web Analytics (SWA) and integrate it with a Fiori Launchpad on SAP Cloud Platform Portal service. Note that the Portal service comes with in-built usage analysis which provides details on the site visits, device/OS/browsers. However, SWA helps you gain more insights on the usage of the site/apps as described in this blog post.

Enable SAP Web Analytics

Navigate to the Subscriptions menu of your SAP Cloud Platform Cloud Foundry account and enable your Web Analytics application. Note that SWA is also available in the trail landscape and you could use it too to explore the capabilities.

If you are using a trial environment, there is a guided mission to onboard SAP Web Analytics.

Before launching the application, you will need to add a role to a “Role Collection”. In the below example, I am adding the highlighted SWA role to my role collection called admin. There are few other roles which are available and you can find more info on the purpose of them in SAP Help

The next step is to select “SAP ID service” (or your configured IdP) to assign the role collection.

Search for your user account and assign the role collection as shown below.

Configure SAP Web Analytics

Navigate back to the subscription menu and launch the “Web Analytics” application. You will first need to define space.   A space is required to manage users/group and websites defined for tracking. You can have several spaces for different business teams. Each team can define the applications their want to track along with access rights for members.

When defining a space, you have the option to select “Visitor Anonymity” if you don’t want to remember the visitors for all sites in this space. You also would need to assign the space admins here. For this example, I have assigned my user ID as a space admin.

Once a space is created, the next task is to create a site. This will represent either your Portal site or your application which you want to track the usage. Click on “Add Site”.

In the “Add Site” window, there are plenty of options to choose that defines the way in which usage tracking will be enabled. In the example below, I have provided the URL of the Fiori Launchpad (without https://). Set the “Tracking Status” to enabled to allow SWA to collect data.

Under the “Privacy Settings”, I have disabled the option “Site used by Employees only” as my Portal is an external facing site. I have also selected “Set as Session” to consider an existing visitor as a new visitor during subsequent visits. Most importantly, I want to obtain a consent from the user before collecting the data. Hence, I have selected “Default Tracking Consent Banner”. There are more settings in the Advanced options. You can go through what each of these settings mean in SAP Help

Once the site is saved, you will now see an entry for it in the Site Management section. In the actions, you can click on the code snippet.

This will give you a Javascript with pubToken and basedURL which will need to be used in the calling application/portal site. Hence make a note of this.

When you navigate to “Home” menu, you will be able to see the tracking data for this particular site. Since we have not yet completed the configuration, there wouldn’t be any data. Notice at the top you can change between different sites, the level of aggregation (Days/month) and also apply filters.

This completes the minimum configuration required in SWA

Configure a Fiori Launchpad Shellplugin

In order to enable to communication between the Portal site/App with SWA, we would need to embed the script which was obtained above. Since I am going to track the usage of the Fiori Launchpad, I am going to use Shell Plugins. There are plenty of blogs out there to show you how to create a Portal site and add a shellplugin to it. I wouldn’t be going to the details of this again.

Here is the code snippet I have used

 

    init: function () {
            var rendererPromise = this._getRenderer();

            window.swa = {
                pubToken: XXXXXXXXXXXXXXXXXXXXXXXXXXX7d455',
                baseUrl: "https://events.wa.cfapps.ap10.hana.ondemand.com/tracker/",
                loggingEnabled: true
            };
            this.loadTracker();
        },

        loadTracker: function () {
            (
                function () {
                    var d = document,
                        g = d.createElement('script'),
                        s = d.getElementsByTagName('script')[0];
                    g.type = 'text/javascript';
                    g.defer = true;
                    g.async = true;
                    g.src = window.swa.baseUrl + 'js/track.js';

                    s.parentNode.insertBefore(g, s);
                    if ((typeof sap !== "undefined" || typeof sap.ui !== "undefined") && sap.ui.version >= "1.65.0") {
                        //no need to track Hash change, as Router event is listened
                    } else {
                        window.onhashchange = function () {
                            window.swa.trackLoad();
                        };
                    }
                })();
        },

I have deployed this shellplugin to my SAP Cloud Platform subaccount and configured my Fiori Launchpad to include this plugin.

When anyone tries to access the Fiori Launchpad, they will now get to see a “Privacy Statement” as a popup to confirm if SWA can collect their usage data. The user can either Allow or Deny the usage tracking. For this example, I am allowing the usage tracking.

Exploring the capabilities of SAP Web Analytics

After navigating the site and accessing the applications, I would be able to see the data being collected in SWA. Below is the view of my Home page in SWA. It gives a summary of information related to visitors, Pages and Technology used (OS/Devices)

To obtain finer details, you navigate to the other menu items. Below is the view obtained from the “Page” menu. It gives you the top/least visited page along with the trends.

Here is the view of the “Technology” menu. It shows the browsers/OS/Device types which are used to access the Fiori Launchpad.

You also have the option to create your own dashboards and Reports accordingly to your requirements. I would like to create a report which shows the number of visitors to each apps in the Fiori Launchpad. Navigate to the “Reports” menu and click on “create report”

Select from the available Measures and Dimensions and preview the data.

After saving the report, you can access the report from the “Reports” menu and also use the chart options to view them in different formats.

At any point, if you want to navigate to the site management, you will find it under the Administration menu.

As you can see there are more menu options here around user/group/data management which will give you more flexibility to define the users, their access rights and their ability to manage and monitor usage data of end users. I would encourage you to try out SAP Web Analytics in the trial environment and explore all these capabilities.

 

Be the first to leave a comment
You must be Logged on to comment or reply to a post.