1

I would like to start monitoring visits to a GeoNetwork instance with Piwik. This requires the addition of a piece of JavaScript like the one below to each page:

<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="//webstats.myserver.org/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '22']);
    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>

So far I understand I must create a .js in the geonetwork/catalog/js folder with this code. What I am yet to grasp is then how to include this file into each page served by this instance. Any clues?

3

You can paste it in <head></head> section in this file: web-app/src/main/webapp/xslt/base-layout.xsl.

  • I added the code block to the header in that file, but when I load GeoNetwork in the browser that piece is not present. Do I need to do something else? – Luís de Sousa Dec 12 '17 at 11:27
  • I am running this from eclipse and restarting jetty server is enough to show for example another meta tag. Are you using war or install version? – user1403588 Dec 12 '17 at 13:13
  • I needed to restart the instance from tomcat. – Luís de Sousa Dec 13 '17 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.