Technical Articles
Site Configuration: SAP Web Analytics
Introduction
Many of you might have already been using SAP Web Analytics tracking application for tracking your websites and people who are not should really try it by subscribing to it on BTP (Business Technology Platform).
Once you have subscribed to “Web Analytics” on Business Technology Platform and go to “Site Management” to add your site for tracking you might be wondering “I see a lot of settings here what are these, are these helpful to me, Do I need to look them in to and so on”. So don’t worry I am writing this blog to explain the different settings involved in “Site Management”.
Basically when you open “SAP Web Analytics” Site Management page and try to add a site you see this dialog as below.
Site Configuration is divided into 3 sections Basic, Privacy and Advanced. Let me explain each of them.
1. Basic Settings
These include domain, name of site, tracking status and site configuration refresh interval.
Basic Settings
- Here website should be your domain name without the protocol and ending /(slash).Eg if url has domain abc.com. Wildcard for domain names with character * is also supported. For Example if you have <app1.test.com> and <app2.test.com> as two different sites then <*.test.com> without angular brackets can be added in Website field to track both sites. (Both of these will share same pub token)Also multiple websites can be added by clicking ‘+’ button to track these as together.Name can be any name of your choice.
2. Name for your Site.
3. Tracking Status has to be kept ON enabling tracking for your websites else your site data will not be collected.
4. Site configuration refresh interval is used to determine the frequency at which the configuration of your need site should be fetched from backend. By default set as 15 days which means every 15 days the configuration is fetched when site is used. If “Refresh on page Load” is selected then every reload of your site the configuration are fetched which might impact the performance.
2. Privacy Settings
This basically will explain how should be the behaviour of your website. Since user data is being tracked consent should be taken from the user and how to achieve this is explained here.
- Do you want it for internal employees only and don’t want to take consent from them and do default tracking when they access the website.: Make the “Site Used by Employees Only” as ON.
Here Remember Visitors denote for how many days you want the visitor to be remembered. You can remember the visitor for a session also by checking “Set as session”.
Privacy Settings
- Do you want it for internal employees only and want to take consent from them while using the website: Make the “Site Used by Employees Only” as ON and in “Account Settings” under Administration “Can you Employees give Consent” as ON.
Account Settings
- If it is for external users, then turn off “Site Used by Employees Only” and then if you want to use consent banner provided by “Web Analytics” keep “Default Tracking Consent Banner” as ON.
- If you want to allow tracking of “Custom Attributes” it can be turned on and then custom attributes being passed are tracked on site usage.
- If you are tracking personal data, then “Custom Attributes containing personal data” switch should be made ON and, in this case, “Web Analytics” banner cannot be used, and it is the responsibility of application to handle the consent mechanism. In this tracking will not happen by default instead swa.enable() should be called from within snippet.
- If “Web Analytics” banner is used and you want your own text to appear in the banner instead of ours when “Customize Consent Text” can be checked in.
3. Advanced Settings
This section enables to add subsites if your site has any and specify if you want the website traffic to be filtered based on the domain.
Advanced Settings
Subsite option can be turned ON and then the subsites can be added by providing name and id.Filter Domain can be turned ON to filter the traffic. If your application is UI5 based and you want to track certain UI5 events “Track UI5 Events” can be set as ON.
Once all these settings are done site can be saved. Once site is saved click on the “Snippet” icon and copy it to your website.
Example:
<script>
var swa = {
pubToken: ‘1fa83507-bef6-4398-91ac-055d4aff3197’,
baseUrl: ‘https://swaqe-tracker.cfapps.sap.hana.ondemand.com/tracker’,
owner: null,
subsiteId:give the subsite id created while creating site.eg s1
//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>
On load of your website if “Web Analytics” banner is used the banner should appear and on user’s consent data will be tracked if banner is not opted then website owner can modify their snippet as below
<script>
var swa = {
pubToken: ‘1fa83507-bef6-4398-91ac-055d4aff3197’,
baseUrl: ‘https://swaqe-tracker.cfapps.sap.hana.ondemand.com/tracker’,
owner: null,
subsiteId: give the subsite id created while creating site.eg s1
//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);
window.addEventListener(“swaLoadSuccess”, function(){
swa.enable();
});
})();
</script>
In this case tracking happens without consent and if site owner have their own banner they can call swa.enable() on their “Allow tracking” action.
Conclusion
After going through this blog post you should be able to understand and use the SAP Web Analytics Site Configuration based on your business needs and enable the webanalytics tracking for your website.
I hope this post will help you to configure your webanalytics site and enable tracking.