Upload
rshanrath
View
796
Download
2
Embed Size (px)
Citation preview
Google Analytics and Primo
Scott Hanrath
University of Kansas Libraries
@rshanrath | [email protected]
Analytics and Discovery
Analytics and Discovery
“…understanding and
optimizing…usage”
Analytics and Discovery
Image: National Archives http://research.archives.gov/description/514671
Implementing Google Analytics
Implementing Google Analytics
Implementing Google Analytics
Event Tracking
“That* Just Happened!”
* Where ‘That’ is a user interaction with, or features of the page that you can intercept via a JavaScript function and parse into an Event you can describe back to Google Analytics.
Event Tracking - Code
ga('send', 'event',
'category', 'action’,
'label’, value);
Category
- - Action
- - - - Label
Event Tracking - Example
$(‘a’).on(‘click’, function(){
ga(‘send’, ‘event’, ‘link-click’,
$(this).text());
});
Category: ‘link-click’
Action: [the text of the link]
Event Tracking – Item Tabs
Event Tracking – Item Tabs
$('.EXLResultTab a').on(‘click’,
function(){
var text = $(this).text();
ga('send', 'event', 'Item Tab', text);
}
);
Event Tracking – Item Tabs
Event Tracking – Item Tabs
Event Tracking – Item Tabs
$('.EXLResultTab a').on(‘click’,
function(){
var text = $(this).text();
var type = $(this).parents('tr')
.find('.EXLThumbnailCaption')
.text();
ga('send', 'event', 'Item Tab', text,
type);
}
);
Event Tracking – Item Tabs
Event Tracking – PNX Interactions
Event Tracking – Applied Facets
Event Tracking – Applied Facets
$('.EXLRefinementRibbonWithExclude .EXLRemoveRefinement').each(
function(){
var container = $(this);
var facet = $.trim(container.contents().filter(
function(){return this.nodeType == 3})[0].nodeValue
);
facet = facet.substr(0, facet.length - 1);
container.find('a').each(function(){
var value = $.trim($(this).text());
if ($(this).hasClass('EXLExcludedElement')){
value = '-'+value;
}
ga('send', 'event', 'Facet Applied', facet, value);
});
}
);
Event Tracking – Applied Facets
Event Tracking – Availability Clicks
Even Tracking – Availability Clicks
Event Tracking – Availability Clicks
Event Tracking - Searches
Event Tracking – Boolean Suggest
Event Tracking—Autocomplete
Event Tracking—Segments
Result Title Clicks per Session
Autosuggest 4.9
Facet Applied 3.5
Advanced Search Any Fields 2.9
Custom Dimensions
https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
Custom Dimensions
Metric, e.g, Pageviews
Metric, e.g., Event Count
Dimension, e.g., Page Title
X X
Dimension, e.g., Event Category
X X
Metric: value of a thing that happened
Dimension: way to group those things
Custom Dimensions – Set up
• Define in Google Analytics Admin for Property
– Up to 20
– Defined by index, e.g, dimension1, dimension2
• Add JavaScript to set:
ga('set', 'dimension1', ’Foo');
Custom Dimensions—Scopes
• Hit – value is applied to the single hit for which it has been set.
• Session – value is applied to all hits in a single session.
• User – value is applied to all hits in current and future sessions, until value changes or custom dimension is made inactive.
From https://developers.google.com/analytics/devguides/platform/customdimsmets
Custom Dimensions—Page Type
• Define dimension with “hit” scope
• Determine which part of Primo is being used (e.g., Basic Search, My Account) by examining the URL with JavaScript– window.location.href
• Set custom dimension before sending page view
Custom Dimensions—Page Type
Custom Dimensions—Borrower Group
• Use Voyager’s Borrower Group for signed in users to create a Custom Dimension
• User scoped Dimension (applies to future sessions too)
• Custom Tile in the Views Wizard Layout Editor
<%@ page import="com.exlibris.primo.utils.SessionUtils" %>
<%@ page import="com.exlibris.primo.pds.PdsUserInfo"%>
<%
boolean logged_in = false;
try {
logged_in = SessionUtils.getIsLoggedIn(request);
} catch(Exception e) {}
%>
<script type="text/javascript">
function addGaUserDimensions(){
<%
PdsUserInfo userInfo = SessionUtils.getUserInfo(request);
if (logged_in && userInfo != null){
%>
ga('set', 'dimension2', '<%= userInfo.getBorGroup() %>');
<%
}
%>
}
</script>
Custom Dimensions—Borrower Group
Custom Dimensions—Borrower Group
Custom Dimensions—Borrower Group
Privacy
• Google Analytics IP Anonymization
ga('set', 'anonymizeIp', true);
• Alternatives
– Piwik (piwik.org)