Solved, I think...

After a little debugging, it looks as if Google Analytics might want a 
real-looking user agent.  In 

  
dspace-api/src/main/java/org/dspace/google/GoogleRecorderEventListener.java

I replaced

  // httpclient = HttpClients.createDefault();   (around line 56)

with:

String userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.18 Safari/537.36"; 
httpclient = HttpClients.custom().setUserAgent(userAgent).build();

voila!  My bitstream downloads are now being accepted as events by GA.  Of 
course, I still can't see the results in dspace, but at least the downloads 
are being recorded in GA now.

Is this a recent change on the Google end?  Has this ever worked 
out-of-the-box for anybody else?  I have exactly the same experience using 
curl.  Straight up curl with the appropriate GET parameters gets me 200/OK, 
but only when I specify a user agent does my request actually get recorded.

Instead of hard-coding the the user agent in the .java code, it should be 
in a .cfg file somewhere.  I'd be happy to make a pull request for this fix 
if you believe I'm barking up the right tree...
Bill

On Friday, February 26, 2016 at 2:21:20 PM UTC-6, Bill T wrote:
>
> Sorry, I asked this question a couple weeks ago, but haven't heard back. 
>  I'll rephrase it a little...  I'm using DSpace v5.4 with Google Analytics 
> enabled.  My page views are being recorded just fine, but I'm not sure 
> about bitstream views.
>
> I realize (https://jira.duraspace.org/browse/DS-2899) that I will not see 
> the results in the interface, but I don't even see them in GA.  I bumped up 
> the log.level to DEBUG and in dspace.log I can see messages like this for 
> every bitstream view:
>
>   Usage event received bitstream:view
>
> followed by
>
>   Google Analytics response is HTTP/1.1 200 OK
>
> and finally
>
>   Posted to Google Analytics - /bitstream/handle/11299/xxxx/yyyy.pdf
>
> so it looks as if all the right things are happening, but I can find no 
> record in GA itself.  Where should I be looking??  I see nothing in 
> Behavior/Site Content/All Pages (as I said, all other page views are 
> counted here).  Are they being recorded elsewhere, or is something else 
> wrong on my end?
>
> Thanks for thinking about it!
> Bill
>

-- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.

Reply via email to