IUG FORUM

Stay always connected!
  1. Margaret Sylvia
  2. Sierra/ Millennium/ Encore
  3. Friday, 12 July 2019
  4.  Subscribe via email
I've been trying to get Google analytics working in our webpac to track outbound links, but not having any luck. Has anyone got this working and could you share with me how you did it? Thanks!

Margaret Sylvia
St. Mary's University Blume Library

msylvia@stmarytx.edu
Comment
There are no comments made yet.
Accepted Answer Pending Moderation
0
Votes
Undo
Hey Margaret,

What element in your WebPac are you trying to track? Below is a general function I used to track outbound clicks in Encore, but I can help you adapt it to your situation. Any click of an "a" element inside of the widgetHeader class were tracked with this:

window.onload = function outboundClicks() {
$j(".widgetHeader a").click(function() {
ga('send', 'event', {
eventCategory: 'Outbound Link',
eventAction: 'click',
eventLabel: this.href,
transport: 'beacon'
});
});
}

-Sean

CwiekS@mcls.org
Comment
There are no comments made yet.
Accepted Answer Pending Moderation
0
Votes
Undo
The focus is to track outbound clicks on 856|u links in order to try to view the use of open access titles we've added to the catalog. We don't use Encore, but EDS. I'm trying to track the links that users click on directly from the webpac.

I'm very much a newbie at Google analytics. So, if you could flesh this out for me a bit, that would be great. My direct email is msylvia@stmarytx.edu, if you'd prefer to use that.

Thanks!

Margaret Sylvia
St. Mary's University Blume Library

msylvia@stmarytx.edu
Comment
There are no comments made yet.
Accepted Answer Pending Moderation
0
Votes
Undo
For outbound links on any web property, I use the following (you would need to insert your property identifier, where I have "YOUR_GA_ID_HERE" below). Just put that in the header code in Encore.

<!-- start Google Analytics script -- insert before closing head tag -->

<script type="text/javascript">

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//http://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-YOUR_GA_ID_HERE', 'auto');
ga('send', 'pageview');



/* Attach tracking to all download & external links */

function _gaLt(event){
var el = event.srcElement || event.target;

/* Loop up the tree through parent elements if clicked element is not a link (eg: an image inside a link) */
while(el && (typeof el.tagName == 'undefined' || el.tagName.toLowerCase() != 'a' || !el.href))
el = el.parentNode;

if(el && el.href){
if(el.href.indexOf(location.host) == -1){ /* external link */
ga("send", "event", "Outgoing Links", el.href, document.location.pathname + document.location.search);
/* if target not set then delay opening of window by 0.5s to allow tracking */
if(!el.target || el.target.match(/^_(self|parent|top)$/i)){
setTimeout(function(){
document.location.href = el.href;
}.bind(el),500);
/* Prevent standard click */
event.preventDefault ? event.preventDefault() : event.returnValue = !1;
}
}

}
}

/* Attach the event to all clicks in the document after page has loaded */
var w = window;
w.addEventListener ? w.addEventListener("load",function(){document.body.addEventListener("click",_gaLt,!1)},!1)
: w.attachEvent && w.attachEvent("onload",function(){document.body.attachEvent("onclick",_gaLt)});

</script>

<!-- end Google Analytics script -->


alison.pruntel@fauquiercounty.gov
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!