Skip to Content
Author's profile photo Preeti Pradhan

PIWIK Analytics on SAP Enterprise Portal 7.4

Introduction :

Piwik is an open analytics platform currently used by individuals, companies and governments all over the world.Piwik is a downloadable, Free (GPL licensed) web analytics software platform. It provides detailed reports on your website and its visitors, including the search engines and keywords they used, the language they speak, which pages they like, the files they download and so much more.

In today’s analytics world, SAP Enterprise portal website can use analytic tool like PIWIK to track site usage.

Many times, we need to have information on atleast one of the following for our SAP EP Website:

•         Measure site activity

•         Analyze User behavior

•         Visitors’ tracking.

•         Analysis of the contents visited (pages, files).

•         Information of the visitors (Browsers, Operating System).


PIWIK provides us with the tag to be used for hitting their server. This tag needs to be on all the pages , we need to track in SAP Portal. Since SAP Portal has many pages/iViews, the script needs to be added to a common place.

In SAP Portal versions 7.0 , we can add the code to Desktop innerpage . If you want to use analytics tool in this version refer my Document :

However in SAP Portal 7.3 and above, the default framework page is Ajax framework page and there is no concept of Desktop innerpage for it.Hence we need to change the file and add the piwik code in this war file.

Implementation Steps :

1)       We need to get the PIWIK tag for each Portal URL. This will be provided by PIWIK team.

<!– Piwik –>

<script type=”text/javascript”>

var pkBaseURL = “<PIWIK server URL>”;

document.write(unescape(“%3Cscript src='” + pkBaseURL + “piwik.js’ type=’text/javascript’%3E%3C/script%3E”));

</script><script type=”text/javascript”>

try {

var piwikTracker = Piwik.getTracker(pkBaseURL + “piwik.php”, 764);

var csusername = ‘anonymous’;

piwikTracker.setCustomData({‘csusername’: csusername});



} catch( err ) {}

</script> <!– End Piwik Tracking Code –>

2)       Download the from your portal and create a custom project on NWDS. It will also create ear file in NWDS.

3)       Rename the project as contentarea.war

4)       In this war file there will be a jar  file “ At this path ” contentarea\WebContent\WEB-INF\private\lib

5)       Unjar this file from command prompt ( Start-Run-CMD) . Go toi the directory where this jar file exists and give command jar –xvf

6)       Two folders will be created COM and meta-inf . we need to change the code in this class file :


7)       Download the JDdecompiler from internet site to get the source code for this class file.

8)       Once you get java file: add the PIWIK code to this file and recompile the file.

9)       Now replace the new class file in folder \WebContent\WEB-INF\private\lib\com\sapportals\portal\navigation

10)   Create a zip file in path \WebContent\WEB-INF\private\lib\. This zip file should have com and Meta-inf folder . Rename this zip file to 

11)   Deploy the war file and ear file on server.

12)   Now create a contentArea iView from the contentarea.war default component.

13)   Go to content admin -> your framework page and open properties. Modify the property URL for contentarea to point to your new Contentarea iView. And save the page

14)   Now when you navigate on any portal page, the hits will be captured by PIWIK code.

PIWIK Output

     Once PIWIK is configured to run on SAP Enterprise portal, all the user hits will be captured by PIWIK server. Below are some of the graphs we can get :


Conclusion :

Thus we can configure our Portal to track Portal hits and get the usage statistics .

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Tobias Hofmann
      Tobias Hofmann

      The proposed solution path should be considered dangerous and not be followed. Altering a standard portal application and redeploying it with the same name puts your SAP Portal installation at risk.

      Either apply the Piwik JS by supplying your own portal application or by using the LS-API provided by the SAP Portal framework.

      Author's profile photo Former Member
      Former Member

      Hi all,

      did anyone of you implemented the solution above.

      I also want to analyze usage of enterprise portal 7,31. I am wondering which solution is the best: PIWIK, Google analytics or any other product?

      Maybe anyone of you can give me good advice.

      Best regards


      Author's profile photo Tobias Hofmann
      Tobias Hofmann

      I did something similar, but instead of decompiling and adding piwik tracker code into the contentarea of SAP code, I developed a simple and small PAR with one JSP file.

      I have this in my to-do pipeline to blog for over a year. Maybe it's time