EPrints Technical Mailing List Archive

Message: #00409


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

[EP-tech] Re: Google analytics


Kalimera Georgios,

I had the same problem than you and I solved with this javascript
code, it consist in adding an event to every download:

/* ----------------------------------------
   Onclick GAv2 Event Generator v1.0
   Denis Pitzalis
   DP: edit.  01/09/2011
   DP: mod. 05/09/2011

   TODO: track unhandled filetype
------------------------------------------- */
(function($) {
  var doctypes = ["doc","docx","xls","zip","pdf","xlsx","gz","ps","xls"];
  var mmtypes = ["wmv","flv","mp3","mp4"];
  var imgtypes = ["tif","png"];

  $(document).ready(function() {
    $("a").click(function(event){
        if($(this).attr("href").length) {
            var source = $(this).attr("href");
            var extension = source.substr(source.lastIndexOf('.') + 1);
            if ( jQuery.inArray(extension,doctypes) > -1 ){
                _gaq.push(['_trackEvent', 'Documents', extension, source]);
            } else if ( jQuery.inArray(extension,mmtypes) > -1 ){
                _gaq.push(['_trackEvent', 'MultiMedia', extension, source]);
            } else if ( jQuery.inArray(extension,imgtypes) > -1 ){
                _gaq.push(['_trackEvent', 'Images', extension, source]);
            } else if ( source.match(/^mailto\:/i) ) {
                _gaq.push(['_trackEvent', 'Mails', "", source]);
            } else {
            }
        }
    });
});

})(jQuery)
/* END Onclick GAv2 Event Generator */

and it works as expected. If it work fine for you too, please tell me!

Denis




On Mon, Apr 16, 2012 at 8:27 PM, Dimitrakakis Georgios
<giorgis@lib.uoc.gr> wrote:
> I have applied GA to the template files and indeed is working as
> expected. But I couldn't find a way to track the PDF downloads with
> that. Have you managed to do it? Can you be more specific?
>
> Regards,
>
> G.
>
>> The GA code can go in the template files:
>> <archive_id>/cfg/lang/xx/templates/*.xml.  The default template will
>>  ensure the abstract pages are tracked (unless you force SSL) but I
>> would add it to all templates to assist with tracking usage across
>> secure-non secure parts of the site.  Note that GA won't track PDF
>> downloads unless you do some extra work.
>>
>> Cheers
>> Mark
>>
>> From: eprints-tech-bounces@ecs.soton.ac.uk
>> [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of
>> Gaston.Fournier@etsmtl.ca
>> Sent: Friday, 13 April 2012 2:24 AM
>> To: eprints-tech@ecs.soton.ac.uk
>> Subject: [EP-tech] Google analytics
>>
>> Allo,
>>
>> I would like to know where (in wich file or files) I should put the
>> code for google analytics?
>>
>> I would like to have a count with GA when a citation is display! Is
>> this possible?
>>
>> Thanks,
>>
>> Gaston Fournier
>> Service de la bibliothèque ÉTS
>>
>>
>
>
>
> --
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
> *** 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/
>



--
----------------------
Denis Pitzalis
Information Technology Consultant

UNESCO - http://www.unesco.org
Paris, France - Tel: +33145681816

Business Strand Coordinator
3D-COFORM - http://www.3dcoform.eu

VAST 2011 - http://www.vast-conference.eu