Skip to Content
Technical Articles
Author's profile photo Murali Shanmugham

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.

Assigned Tags

      18 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Pedro Cain Molina Conesa
      Pedro Cain Molina Conesa

      hello, could you please add a link/ explain how to add shell plugins on cloud foundry portal, i've been unable so far to do it

      Author's profile photo Murali Shanmugham
      Murali Shanmugham
      Blog Post Author

      Hi Pedro,

      Shell Plugin in Cloud Foundry Portal is still in the roadmap. Should be made available sometime soon.

      Author's profile photo Aviad Rivlin
      Aviad Rivlin

      Note: Shell Plug-ins in Cloud Foundry Portal is now available.

      Author's profile photo Waldemar Koch
      Waldemar Koch

      Hi Aviad

      I need the Shell Plug-in to integrate SAP Conversational AI and SAP Web Analytics.

      Can you please provide additional information how we can install it in a Central Fiori Launchpad or in a free style portal site?

       

      Thanks

      Waldemar

      Author's profile photo Pedro Pereira
      Pedro Pereira

      Hi! Is this avaible or still in the roadmap?

       

      Author's profile photo Andrea Bosoni
      Andrea Bosoni

      Hi, would this work also with an on premise Fiori launchpad?

      Author's profile photo Murali Shanmugham
      Murali Shanmugham
      Blog Post Author

      Hi Andrea,

      Yes, it would work on any solution that allows us to embed the scripts to track the usage. Hence, you should be able to extend the on-premise Fiori launchpad by using shell plugins and make calls to the Web Analytics service

      Author's profile photo Ludovic Bento
      Ludovic Bento

      Hi, does anyone know how to connect this solution with an on premise LaunchPad ?

      Thanks

      Author's profile photo Younong Wang
      Younong Wang

      Hi,does it could not work at on premise,i meet the same questions.

      Author's profile photo Tim Jones
      Tim Jones

      Not sure if you found an answer to this but this Blog covers linking an on-premise FLP.

       

      https://blogs.sap.com/2020/08/05/measuring-sap-fiori-user-statistics-with-sap-web-analytics/

      Author's profile photo George Abraham
      George Abraham

      Hi Murali,

      Thanks for this blog esp on the shell plugin how to integrate as it helped a lot.

      I had a question though - we use the SDK for iOS to build native apps - is there a way that we can use Web Analytics to track user demographics of native apps as well?

      Hybrid apps I believe should be fine as they are anyways configured on the FLP and will be tracked, but what about native ones?

      Author's profile photo Ramlingam Arunbharani
      Ramlingam Arunbharani

      I am getting this error while implementing the code snippet.

       

      abap.js:63 2020-07-14 00:00:13.165899 Cannot create UI5 plugin component: (componentId/appdescrId :com.webanalytics.fiori.com.WebAnal)
      TypeError: this._getRenderer is not a function properties {"ui5ComponentName":"com.webanalytics.fiori.com.WebAnal","url":"/sap/bc/ui5_ui5/sap/zwebanalytics/~F6A1E9A50E435811E374EF45D01E7E5C~5","applicationDependencies":{"url":"/sap/bc/ui5_ui5/sap/zwebanalytics/~F6A1E9A50E435811E374EF45D01E7E5C~5","manifest":"/sap/bc/lrep/content/~20200714025332.0694770~/apps/com.webanalytics.fiori.com.WebAnal/app/sap/zwebanalytics/manifest.appdescr","self":{"name":"com.webanalytics.fiori.com.WebAnal","url":"/sap/bc/ui5_ui5/sap/zwebanalytics/~F6A1E9A50E435811E374EF45D01E7E5C~5"},"asyncHints":{"libs":[{"name":"sap.ui.core"},{"name":"sap.ui.layout"},{"name":"sap.m"}],"requests":[{"name":"sap.ui.fl.changes","reference":"com.webanalytics.fiori.com.WebAnal.Component"}]},"enabled":true,"loaded":true,"name":"com.webanalytics.fiori.com.WebAnal"}}
      This indicates a plugin misconfiguration, see e.g. Note 2316443. - TypeError: this._getRenderer is not a function

       

      Any suggestions.

       

      Thanks

      Arun

      Author's profile photo Gregor Wolf
      Gregor Wolf

      Hi Murali,

      I've tried to use your code in a Shell Plugin that I've developed following the post Developing a Shell Plugin for SAP Fiori Launchpad on SAP Cloud Platform, Cloud Foundry environment with SAP Business Application Studio by Soeren Holst. The Launchpad tries to load the Plugin but unfortunately I get a bad gateway for all the tried URL's:

      Can you try it and perhaps update your post?

      Best regards
      Gregor

      Author's profile photo Murali Shanmugham
      Murali Shanmugham
      Blog Post Author

      Hi Gregor,

      I haven't tried this yet with the Business Application Studio. Will check when I get some time. Thanks.

      Author's profile photo Antonette Venter
      Antonette Venter

      Hi Murali,

       

      Thanks for the blog. Can Web Analytics track activity in other subaccounts?

       

      Regards

      Antonette

      Author's profile photo Murali Shanmugham
      Murali Shanmugham
      Blog Post Author

      Yes, it can track activity of of apps which are deployed in another subaccount.

      Author's profile photo Zameer Ahamad
      Zameer Ahamad

      Hi Murali,

      Thanks for the detailed blog about SAP web analytics. We are using the same way to get the statistics of the applications.

      We have several applications integrated with Web analytics and we have correct data for most of the applications but for one of our application, we are seeing more Avg visit duration time spent for the application. That is not true.

      All the applications are same in terms of code deployment and only difference I can see the particular application uses SAP IAS(Identity Authentication Services) IDP for authentication and authorization.

      We found one setting in SAP IAS, and we adjusted the session logout in IAS Tenant setting.

      Default it was set to 12 hours and then later we changed to 30 Minutes past few days.

      Now the application is logging out at 30 minutes but the problem is the SAP web analytics report shows Avg visit duration time is still more and it is not valid.

      is there any additional setting need to be performed if we are using SAP IAS identity provider for the application to capture Avg visit duration time apart from session logout setting.

       

      Author's profile photo Simon Peichl
      Simon Peichl

      Hi Murali,

       

      thanks for the blog. I've tried to use your code in a Shell Plugin, but I get a

      TypeError: this.getRenderer is not a function

      Is there maybe a specific UI5 version to use?

       

      Kind Regards

      Simon