Topic: Piwik Analytics

Hi!

Has anyone experience how to analyze Juicebox picture galleries with Piwik?
I enabled Direct Links and added the Piwik-code in the "index.html". But unfortunately it's not working.

My Piwik-code:
    </script>
<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//www...../analytics/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Piwik Code -->


Thanks
Roman

Re: Piwik Analytics

Using the standard Piwik analytics code will log hits to just the gallery's web page.

Setting enableDirectLinks="TRUE" in your gallery will give each image in the gallery a unique URL (using a # identifier at the end of the URL) but the web page is not refreshed/reloaded each time a new image is selected so the analytics code will not be rerun (it will be run only once when the web page is initially loaded).

You'll likely need to manually register a hit each time a new image is selected using the Juicebox-Pro API's onImageChange(e) event.

Keep the standard Piwik code in your gallery's web page and then use something like the code below:

<script type="text/javascript" src="jbcore/juicebox.js"></script>
<script type="text/javascript">
    var jb = new juicebox({
        containerId: "juicebox-container",
        enableDirectLinks: "TRUE"
    });
    jb.onImageChange = function(e) {
        var imageNumber = e.id;
        _paq.push(['trackEvent', 'Juicebox', 'Gallery', imageNumber]);
    };
</script>
<div id="juicebox-container"></div>

You might need to check with Piwik's Event Tracking support page for the correct JavaScript code to use (and you can change the terms 'Juicebox' and 'Gallery' to suit your own needs).

I hope this points you in the right direction.