EPrints Technical Mailing List Archive

Message: #08619

< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] Adding analytics tracking code to EPrints

Hi Ravi,

This should be farily straightforward.  Edit you archive's lang/en/templates/default.xml and lang/en/templates/default_internal.xml and add the following markup in the <head> section of the template, (updating to include your UA number):

  <script type="text/_javascript_">
          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);

          (function() {
            var ga = document.createElement('script'); ga.type = 'text/_javascript_'; ga.async = true;
            ga.src = "" == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

Once you have done this you will need to run generate_static as you mentioned.  Non-static pages should automatically update and browse views either will be updated next time generate_views runs or their cache expires. You may want to click on the Regenerate Views and Regenerate Abstracts buttons on the Admin Page -> System Tools menu to make 100% certain all pages are updated to include Google Analytics but I don't think this is technically necessary.


David Newman

On 19/05/2021 12:23, Ravi M via Eprints-tech wrote:
CAUTION: This e-mail originated outside the University of Southampton.

I'd like to add an analytics tracking code on my EPrints site. The code is supposed to be added to the <head> section of HTML files, but the static pages in EPrints are generated via bin/generate_static. I'm not sure how to proceed, and I couldn't find anything about this in the documentation. Would anyone be able to help?

Best wishes,

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/

Virus-free. www.avg.com