|
From: <hs...@us...> - 2011-05-17 20:17:32
|
Revision: 870
http://treebase.svn.sourceforge.net/treebase/?rev=870&view=rev
Author: hshyket
Date: 2011-05-17 20:17:26 +0000 (Tue, 17 May 2011)
Log Message:
-----------
Adding in Google Analytics tracking functionality
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/decorators/adminTemplate.jsp
trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp
trunk/treebase-web/src/main/webapp/decorators/defaultTemplate.jsp
trunk/treebase-web/src/main/webapp/decorators/mainTemplate.jsp
Added Paths:
-----------
trunk/treebase-web/src/main/webapp/common/googleAnalytics.jsp
trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js
Added: trunk/treebase-web/src/main/webapp/common/googleAnalytics.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/common/googleAnalytics.jsp (rev 0)
+++ trunk/treebase-web/src/main/webapp/common/googleAnalytics.jsp 2011-05-17 20:17:26 UTC (rev 870)
@@ -0,0 +1,15 @@
+<%@include file="/common/taglibs.jsp" %>
+<script type="text/javascript" src="<c:url value='/scripts/googleAnalytics.js'/>"></script>
+<script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-23411098-1']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+</script>
\ No newline at end of file
Modified: trunk/treebase-web/src/main/webapp/decorators/adminTemplate.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/decorators/adminTemplate.jsp 2011-05-17 19:19:58 UTC (rev 869)
+++ trunk/treebase-web/src/main/webapp/decorators/adminTemplate.jsp 2011-05-17 20:17:26 UTC (rev 870)
@@ -61,6 +61,6 @@
<!-- BEING FOOTER -->
<div id="footer"><c:import url="/common/footer.jsp" /></div>
</div> <!-- END WRAP -->
-
+<jsp:include page="/common/googleAnalytics.jsp"/>
</body>
</html>
\ No newline at end of file
Modified: trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp 2011-05-17 19:19:58 UTC (rev 869)
+++ trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp 2011-05-17 20:17:26 UTC (rev 870)
@@ -158,6 +158,6 @@
<!-- BEGIN FOOTER -->
<div id="footer"><c:import url="/common/footer.jsp" /></div>
</div> <!-- END WRAP -->
-
+<jsp:include page="/common/googleAnalytics.jsp"/>
</body>
</html>
\ No newline at end of file
Modified: trunk/treebase-web/src/main/webapp/decorators/defaultTemplate.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/decorators/defaultTemplate.jsp 2011-05-17 19:19:58 UTC (rev 869)
+++ trunk/treebase-web/src/main/webapp/decorators/defaultTemplate.jsp 2011-05-17 20:17:26 UTC (rev 870)
@@ -104,6 +104,6 @@
<!-- BEING FOOTER -->
<div id="footer"><c:import url="/common/footer.jsp" /></div>
</div> <!-- END WRAP -->
-
+<jsp:include page="/common/googleAnalytics.jsp"/>
</body>
</html>
\ No newline at end of file
Modified: trunk/treebase-web/src/main/webapp/decorators/mainTemplate.jsp
===================================================================
--- trunk/treebase-web/src/main/webapp/decorators/mainTemplate.jsp 2011-05-17 19:19:58 UTC (rev 869)
+++ trunk/treebase-web/src/main/webapp/decorators/mainTemplate.jsp 2011-05-17 20:17:26 UTC (rev 870)
@@ -28,6 +28,6 @@
<!-- BEING FOOTER -->
<div id="footer"><jsp:include page="/common/footer.jsp"/></div>
</div> <!-- END WRAP -->
-
+<jsp:include page="/common/googleAnalytics.jsp"/>
</body>
</html>
\ No newline at end of file
Added: trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js
===================================================================
--- trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js (rev 0)
+++ trunk/treebase-web/src/main/webapp/scripts/googleAnalytics.js 2011-05-17 20:17:26 UTC (rev 870)
@@ -0,0 +1,61 @@
+// This javascript tags file downloads and external links in Google Analytics.
+// You need to be using the Google Analytics New Tracking Code (ga.js)
+// for this script to work.
+// To use, place this file on all pages just above the Google Analytics tracking code.
+// All outbound links and links to non-html files should now be automatically tracked.
+//
+// This script has been provided by Goodwebpractices.com
+// Thanks to ShoreTel, MerryMan and Colm McBarron
+//
+// www.goodwebpractices.com
+// VKI has made changes as indicated below.
+
+if (document.getElementsByTagName) {
+ // Initialize external link handlers
+ var hrefs = document.getElementsByTagName("a");
+ for (var l = 0; l < hrefs.length; l++) {
+ // try {} catch{} block added by erikvold VKI
+ try{
+ //protocol, host, hostname, port, pathname, search, hash
+ if (hrefs[l].protocol == "mailto:") {
+ startListening(hrefs[l],"click",trackMailto);
+ } else if (hrefs[l].hostname == location.host) {
+ var path = hrefs[l].pathname + hrefs[l].search;
+ var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3|nex)($|\&|\?)/);
+ if (isDoc) {
+ startListening(hrefs[l],"click",trackExternalLinks);
+ }
+ } else if (!hrefs[l].href.match(/^javascript:/)) {
+ startListening(hrefs[l],"click",trackExternalLinks);
+ }
+ }
+ catch(e){
+ continue;
+ }
+ }
+}
+
+function startListening (obj,evnt,func) {
+ if (obj.addEventListener) {
+ obj.addEventListener(evnt,func,false);
+ } else if (obj.attachEvent) {
+ obj.attachEvent("on" + evnt,func);
+ }
+}
+
+function trackMailto (evnt) {
+ var href = (evnt.srcElement) ? evnt.srcElement.href : this.href;
+ var mailto = "/mailto/" + href.substring(7);
+ if (typeof(pageTracker) == "object") pageTracker._trackPageview(mailto);
+}
+
+function trackExternalLinks (evnt) {
+ var e = (evnt.srcElement) ? evnt.srcElement : this;
+ while (e.tagName != "A") {
+ e = e.parentNode;
+ }
+ var lnk = (e.pathname.charAt(0) == "/") ? e.pathname : "/" + e.pathname;
+ if (e.search && e.pathname.indexOf(e.search) == -1) lnk += e.search;
+ if (e.hostname != location.host) lnk = "/external/" + e.hostname + lnk;
+ if (typeof(pageTracker) == "object") pageTracker._trackPageview(lnk);
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|