Why Web Analytics for Business Apps?
If you want to gather Usage data for your business apps, Web Analytics Software provides useful insights and answers to questions like
- How many Users are using the App?
- What is the Users Average Visit Duration?
- Where do User come from (geographically)?
- What End-Devices is your App used with?
- What actions were done by Users within your Apps?
- How can individual Event within the App be tracked?
- … and much more
To define performance and success metrics for your business apps gives you the opportunity to track, measure and report Key Performance Indicators (KPI) that fuel the Return on Investment of your App.
Prerequisites
- Simplifier Server with a Business App that you want to get Usage Insights on
- Web Analytics Software e.g. Matomo, Google Analytics, SAP Web Analytics or similar
- In this example we will look at SAP Web Analytics, which is a Cloud Service offered by SAP Business Technology Platform that provides lots of Insights for Web / Mobile Application Usage.
For more information on SAP Web Analytics please have a look at the SAP Web Analytics and Create Custom Reports for SAPUI5 Apps
Step 1 – Get the tracking Code
Login to SAP Business Technology Platform and follow the Tutorial from the SAP Developer Page
After successful setup of SAP Web Analytics and your Application you can acquire the JS Tracking Code. The Tracking code looks like this:
<script> var swa = { pubToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx', baseUrl: 'https://events.web-analytics.cfapps.eu10.hana.ondemand.com/tracker/', owner: null //set this to a function that returns the identifier of the tracked user }; (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=swa.baseUrl+'js/track.js'; s.parentNode.insertBefore(g,s); })(); </script>
We will copy this code to the Clipboard and create a new Client-Side Business Object on a Simplifier Server. Let’s call it “SAP_WebAnalytics”. Now we create a new function within the Business Object called “initTracker”. We will need to Input Parameters named “pubToken” and “baseUrl” of type “String” that we will use within our function’s code:
Next up we will paste in the Tracking Code that we copied earlier without the script tags which will loke like this:
Now we will replace the attributes “pubToken” and “baseUrl” with our previously created input parameters. Input parameters of Client Side Business Objects can be accessed via “oPayload.nameofParameter” so in our case: oPayload.pubToken and oPayload.baseUrl
Also we will attach the swa variable from the Tracking Code to the window object.
window.swa = { pubToken: oPayload.pubToken, baseUrl: oPayload.baseUrl, owner: null //set this to a function that returns the identifier of the tracked user }; (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=swa.baseUrl+'js/track.js'; s.parentNode.insertBefore(g,s); })();
We can now set the input parameters value to our pubToken and the baseUrl of SAP Web Analytics:
Within our App that we want to gather Usage Statistics for we simply call the “initTracker” function of our Business Object “onInit” of our first Screen to initalize the tracker:
Now that we have initialized the Tracking Code, our Application will be tracked on the SAP Web Analytics Dashboard