Project

General

Profile

Support #441

Updated by Daniel Curtis over 9 years ago

Owncloud is a great web application with many feature and third-party apps. However it currently does not have any apps to integrate a piwik tracking code to obtain visitor analytics. Luckily the code can be inserted into a few files to allow piwik to work on owncloud. When a new tracking code has been created in piwik, they can be added to a couple files need to be momdified and one file added: the following files: 
 # lib/base.php core\templates\layout.user.php 
 # config/config.php core\templates\layout.guest.php 
 # core/templates/piwik-tracking.php 

 h3. lib/base.php 

 * The base ownCloud php file needs to be modified by adding the following code +before+ the @</body>@ tag: 
 <pre> 
 <?php if(PIWIKTRACKING) { get_template_part('templates/piwik-tracking'); } ?> 
 </pre> 

 h3. config/config.php 

 * The ownCloud config php file needs to be modified by adding the following code at the end of the file: 
 <pre> 
 // Enables or disables the piwik tracking code ( 0 = disable / 1 = enable) 
 define(PIWIKTRACKING, 1); 
 </pre> 

 h3. core/templates/piwik-tracking.php 

 * The piwik-tracking.php file must be created and the following code added/modified to it: 
 <pre> 
 <!-- Piwik --> 
 <script type="text/javascript"> 
 var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.example.com/" : "http://piwik.example.com/"); 
 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", 2); 
 piwikTracker.trackPageView(); 
 piwikTracker.enableLinkTracking(); 
 } catch( err ) {} 
 </script><noscript><p><img src="http://piwik.example.com/piwik.php?idsite=2&rec=1" style="border:0" alt="" /></p></noscript> 
 <!-- End Piwik Tracking Code --> 
 </pre> apps\files_sharing\templates\public.php 

 h2. Resources 

 * https://forum.owncloud.org/viewtopic.php?f=23&t=10500

Back