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).

Untitled.png

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 : http://scn.sap.com/docs/DOC-39121

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 com.sap.portal.navigation.contentarea.war 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});

piwikTracker.trackPageView();

piwikTracker.enableLinkTracking();

} catch( err ) {}

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

2)       Download the com.sap.portal.navigation.contentarea.war 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 “com.sap.portal.navigation.contentarea_core.jar 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 com.sap.portal.navigation.contentarea_core.jar

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

\WebContent\WEB-INF\private\lib\com\sapportals\portal\navigation\workAreaIview.class

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 com.sap.portal.navigation.contentarea_core.jar 

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 :

Untitled.png

Conclusion :

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

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. 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.

    (0) 
  2. Jesper Christensen

    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

    Jesper

    (0) 
    1. 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

      (0) 

Leave a Reply