OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



OJS Plugin: Piwik

The Plugin Gallery is a venue for users of PKP software to share their plugins.

Moderators: jmacgreg, michael, John

Forum rules
If you post a plugin here, please include information on which versions of which applications it is compatible with. Attach a tarball of the plugin (e.g. tar cvzf myPlugin-0.1.tar.gz plugins/generic/myPlugin). Thanks for contributing!

OJS Plugin: Piwik

Postby vlilloh » Thu Dec 18, 2008 10:16 am

Piwik Plugin based at the Google Analytics and phpMyVisites plugins, and it works the same way.

It works perfectly on OJS 2.2.2 and Piwik 0.2.26.

"Piwik is a downloadable, open source (GPL licensed) web analytics software program. It provides you with detailed reports on your website visitors: the search engines and keywords they used, the language they speak, your popular pages… and so much more.
Piwik aims to be an open source alternative to Google Analytics.
Piwik is a PHP MySQL software program that you download and install on your own webserver. At the end of the five minute installation process you will be given a JavaScript tag. Simply copy and paste this tag on websites you wish to track (or use an existing plugin to do it automatically for you)"

The existing plugin for OJS this would be. Already there are Piwik plugins for Wordpress, Drupal, Typo3, Mediawiki, ...
Attachments
piwik-0.2.26-plugin.tar.gz
(4.67 KiB) Downloaded 766 times
vlilloh
 
Posts: 276
Joined: Thu Feb 07, 2008 3:35 am
Location: Murcia, Spain

Re: OJS Plugin: Piwik

Postby jmacgreg » Thu Dec 18, 2008 11:31 am

That's great, Vlilloh! I've closed our bug report regarding this: http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=3909. Many thanks for the contribution!

James
jmacgreg
 
Posts: 4162
Joined: Tue Feb 14, 2006 10:50 am

Re: OJS Plugin: Piwik

Postby kekropas » Tue Jan 06, 2009 5:05 am

Why piwik can't recognise pdf files as download? It counts them only on how many times the pdf plugin is used. Is there any why to receive information on which pdf is downloaded last or the top 5 downloads?
kekropas
 
Posts: 38
Joined: Sat Dec 20, 2008 5:56 am

Re: OJS Plugin: Piwik

Postby luiz_borges » Mon Aug 16, 2010 10:10 am

I made a few changes in this plug-in so it would work with the most recent version of Piwik (v0.9). Also, I moved the output from a template to the php code. I think it works better in terms of legibility considering the amount of javascript in the code.

Also, I added the function call setDocumentTitle() with the path of the journal, that way you can use a single profile to gather information from all journals, but still agregate the visitors count in a per-journal mode.

As for locales, I mantained the english one and added a portuguese locale, I haven't keep the spanish locale.

Luiz Borges
Attachments
piwik-v0.9.zip
(7.49 KiB) Downloaded 348 times
luiz_borges
 
Posts: 29
Joined: Tue Jun 30, 2009 1:44 pm
Location: Araraquara-SP / Brasil

Re: OJS Plugin: Piwik

Postby marchitelli » Sun Feb 13, 2011 1:43 am

Hi,
I tried to use the plugin, but it makes an error on the system (in /pages/manager/pluginHandler.php r. 86).
The javascript, moreover, doesn't appear in the page.

In attach, italian translation of the plugin.

Andrea
Attachments
locale.xml
(2.15 KiB) Downloaded 214 times
marchitelli
 
Posts: 105
Joined: Tue May 22, 2007 12:44 am

Re: OJS Plugin: Piwik

Postby jmacgreg » Thu Feb 17, 2011 1:37 pm

Hi Luiz, Andrea,

Thanks for the updates! I have reopened a previous report to Bugzilla (see http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=3909) to add this new plugin to our system.

Cheers,
James
jmacgreg
 
Posts: 4162
Joined: Tue Feb 14, 2006 10:50 am

Re: OJS Plugin: Piwik

Postby tarek » Tue Feb 22, 2011 10:14 pm

Similarly, I can't get the JS code to show up. The code I'm trying to use is:

Code: Select all
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://analytics.openmedicine.ca/" : "http://analytics.openmedicine.ca/");
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", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://analytics.openmedicine.ca/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Tag -->


It simply makes any template in which it appears not display at all.

Any ideas how to debug?

tarek : )
tarek
 
Posts: 14
Joined: Thu Jun 21, 2007 4:00 am

Re: OJS Plugin: Piwik

Postby asmecher » Wed Feb 23, 2011 10:32 am

Hi Tarek,

Smarty uses { and } for its own purposes (see http://smarty.net); try enclosing your Javascript in {literal} {/literal} tags, or using {ldelim} and {rdelim} everywhere in the JS where you would use { and }, respectively.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 7717
Joined: Wed Aug 10, 2005 12:56 pm

Re: OJS Plugin: Piwik

Postby tarek » Thu Feb 24, 2011 12:28 am

Aha! That worked great. Thank you.

tarek : )
tarek
 
Posts: 14
Joined: Thu Jun 21, 2007 4:00 am

Re: OJS Plugin: Piwik

Postby jmacgreg » Wed Nov 09, 2011 10:50 pm

Hi folks,

I've committed the plugin (including the Italian translation) to our master branch, which you can see at http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=3909. Thanks once again for contributing!

Cheers,
James
jmacgreg
 
Posts: 4162
Joined: Tue Feb 14, 2006 10:50 am

Re: OJS Plugin: Piwik

Postby mbria » Wed May 02, 2012 9:40 am

Hi all,

Is this plugin tested against last OJS versions?

I'm trying it on a OJS 2.3.6 and the tracking script didn't appear in most of the pages... while GoogleAnalytics does. :-(

Cheers,
m.
mbria
 
Posts: 279
Joined: Wed Dec 14, 2005 4:15 am

Re: OJS Plugin: Piwik

Postby mbria » Wed May 02, 2012 10:00 am

More info:

Now I tested on a clean OJS 2.3.6 (without restfull_url) and I can confirm the tracking script did NOT appear at:

    Home page
    Current Number
    List of archives
    Article's page
    PDF download
    Help
    Reading Tools
    ...

To be more precise, I just see the script at /manager/plugins/*

I reviewed the code and template registering looks fine to me:

Code: Select all
   function register($category, $path) {
      $success = parent::register($category, $path);
      if (!Config::getVar('general', 'installed')) return false;
      $this->addLocaleData();
      if ($success) {
         // Insert Piwik page tag to common footer 
         HookRegistry::register('Templates::Common::Footer::PageFooter', array($this, 'insertFooter'));

         // Insert Piwik page tag to article footer
         HookRegistry::register('Templates::Article::Footer::PageFooter', array($this, 'insertFooter'));

         // Insert Piwik page tag to article interstitial footer
         HookRegistry::register('Templates::Article::Interstitial::PageFooter', array($this, 'insertFooter'));

         // Insert Piwik page tag to article pdf interstitial footer
         HookRegistry::register('Templates::Article::PdfInterstitial::PageFooter', array($this, 'insertFooter'));

         // Insert Piwik page tag to reading tools footer
         HookRegistry::register('Templates::Rt::Footer::PageFooter', array($this, 'insertFooter'));

         // Insert Piwik page tag to help footer
         HookRegistry::register('Templates::Help::Footer::PageFooter', array($this, 'insertFooter'));
      }
      return $success;
   }


As well as inserFooter function:

Code: Select all
   function insertFooter($hookName, $params) {
      if ($this->getEnabled()) {
         $smarty = &$params[1];
         $output = &$params[2];
         $journal = &Request::getJournal();
         $journalId = $journal->getJournalId();
         $journalPath = $journal->getPath();
         $piwikSiteId = $this->getSetting($journalId, 'piwikSiteId');
         $piwikUrl = $this->getSetting($journalId, 'piwikUrl');
         if (!empty($piwikSiteId) && !empty($piwikUrl)) {
            $output =    '<!-- Piwik -->'.
                  '<script type="text/javascript">'.
                  'var pkBaseURL = "'.$piwikUrl.'/";'.
                  '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", '.$piwikSiteId.');'.
                  'piwikTracker.setDocumentTitle("'.$journalPath.'");'.
                  'piwikTracker.trackPageView();'.
                  'piwikTracker.enableLinkTracking();'.
                  '} catch( err ) {}'.
                  '</script><noscript><p><img src="'.$piwikUrl.'/piwik.php?idsite='.$piwikSiteId.'" style="border:0" alt="" /></p></noscript>'.
                  '<!-- End Piwik Tag -->';
         }
      }
      return false;
   }


Any clue about what could be happening?

Thanks in advance,
m.
mbria
 
Posts: 279
Joined: Wed Dec 14, 2005 4:15 am

Re: OJS Plugin: Piwik

Postby upsam » Sun Mar 24, 2013 1:33 pm

Hi,

I have installed OJS v2.3.8 and I wonder if it is possible to integrate it with Piwik.

Thanks in advance
upsam
 
Posts: 3
Joined: Sun Feb 24, 2013 10:39 am


Return to Plugin Gallery

Who is online

Users browsing this forum: No registered users and 1 guest