ga.jsp 1.09 KB
Newer Older
1
<%@ include file="/WEB-INF/jsp/init.jsp" %>
Matija Obreza's avatar
ga.jsp  
Matija Obreza committed
2 3

<c:if test="${googleAnalyticsAccount ne null}">
Matija Obreza's avatar
Matija Obreza committed
4 5 6 7 8 9
<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','//www.google-analytics.com/analytics.js','ga');

Matija Obreza's avatar
Matija Obreza committed
10
ga('create', '<c:out value="${googleAnalyticsAccount}" />', 'auto');
Matija Obreza's avatar
Matija Obreza committed
11 12
var p={};
try {
13
	if (_pageDim && _pageDim.institute != null) {
Matija Obreza's avatar
Matija Obreza committed
14 15
		p.dimension1=_pageDim.institute;
	}
16
	if (_pageDim && _pageDim.genus != null) {
Matija Obreza's avatar
Matija Obreza committed
17 18 19 20 21 22 23 24
		p.dimension2=_pageDim.genus;
	}
	console.log(p);
	ga('send', 'pageview', p);
} catch (e) {
	console.log(e);
	ga('send', 'pageview');
}
Matija Obreza's avatar
ga.jsp  
Matija Obreza committed
25

Matija Obreza's avatar
Matija Obreza committed
26 27
// Other trackers?
try {
28
	if (_pageTrackers && _pageTrackers.length > 0) {
Matija Obreza's avatar
Matija Obreza committed
29 30 31 32 33 34 35 36 37 38
		for (var i=_pageTrackers.length-1; i>=0; i--) {
			var trackerName='gat'+i;
			ga('create', _pageTrackers[i], 'auto', {'name': trackerName});
			ga(trackerName+'.send', 'pageview');
		}
	}
} catch (e) {
	console.log(e);
}
</script>
Matija Obreza's avatar
ga.jsp  
Matija Obreza committed
39
</c:if>