Difference between revisions of "SUNScholar/Google/Analytics"
Jump to navigation
Jump to search
m |
m |
||
| Line 13: | Line 13: | ||
We were sent the following javascript code snippet to add to the XSL stylesheet file:<br> '''<tt>/home/dspace/source/dspace/modules/xmlui/src/main/webapp/themes/Mirage-SUNScholar/lib/xsl/core/page-structure.xsl''' | We were sent the following javascript code snippet to add to the XSL stylesheet file:<br> '''<tt>/home/dspace/source/dspace/modules/xmlui/src/main/webapp/themes/Mirage-SUNScholar/lib/xsl/core/page-structure.xsl''' | ||
| + | <pre> | ||
| + | <!-- Add a google analytics script if the key is present | ||
| + | <xsl:if test="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='google'][@qualifier='analytics']"> | ||
| + | <script type="text/javascript"><xsl:text> | ||
| + | var _gaq = _gaq || []; | ||
| + | _gaq.push(['_setAccount', '</xsl:text><xsl:value-of select="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='google'][@qualifier='analytics']"/><xsl:text>']); | ||
| + | _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); | ||
| + | })(); | ||
| + | </xsl:text></script> | ||
| + | </xsl:if> | ||
| + | --> | ||
| + | |||
| + | <!-- Piwik W Klapwijk 2012-01 --> | ||
| + | <xsl:if test="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='google'][@qualifier='analytics']"> | ||
| + | <script type="text/javascript"> | ||
| + | <xsl:text>var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.sun.ac.za/" : "http://piwik.sun.ac.za/");</xsl:text> | ||
| + | <xsl:text>document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));</xsl:text> | ||
| + | </script> | ||
| + | |||
| + | <script type="text/javascript"> | ||
| + | <xsl:text> | ||
| + | try { | ||
| + | </xsl:text> | ||
| + | <xsl:text>var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 3); </xsl:text> | ||
| + | <xsl:text>piwikTracker.trackPageView();</xsl:text> | ||
| + | <xsl:text>piwikTracker.enableLinkTracking();</xsl:text> | ||
| + | <xsl:text> | ||
| + | } | ||
| + | catch( err ) { | ||
| + | } | ||
| + | </xsl:text> | ||
| + | </script> | ||
| + | </xsl:if> | ||
| + | </pre> | ||
==References== | ==References== | ||
*https://wiki.duraspace.org/display/DSDOC18/Configuration#Configuration-XMLUISpecificConfiguration | *https://wiki.duraspace.org/display/DSDOC18/Configuration#Configuration-XMLUISpecificConfiguration | ||
Revision as of 08:43, 19 August 2014
Back to Google
Open your main DSpace config file and look for:
xmlui.google.analytics.key
Enter your google analytics key.
Piwik
An alternative is to use your own Piwik statistics server. See: http://piwik.org.
Our campus server is available at: http://piwik.sun.ac.za. The administrator setup an account for us and added http://scholar.sun.ac.za as a service.
We were sent the following javascript code snippet to add to the XSL stylesheet file:
/home/dspace/source/dspace/modules/xmlui/src/main/webapp/themes/Mirage-SUNScholar/lib/xsl/core/page-structure.xsl
<!-- Add a google analytics script if the key is present
<xsl:if test="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='google'][@qualifier='analytics']">
<script type="text/javascript"><xsl:text>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '</xsl:text><xsl:value-of select="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='google'][@qualifier='analytics']"/><xsl:text>']);
_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);
})();
</xsl:text></script>
</xsl:if>
-->
<!-- Piwik W Klapwijk 2012-01 -->
<xsl:if test="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element='google'][@qualifier='analytics']">
<script type="text/javascript">
<xsl:text>var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.sun.ac.za/" : "http://piwik.sun.ac.za/");</xsl:text>
<xsl:text>document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));</xsl:text>
</script>
<script type="text/javascript">
<xsl:text>
try {
</xsl:text>
<xsl:text>var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 3); </xsl:text>
<xsl:text>piwikTracker.trackPageView();</xsl:text>
<xsl:text>piwikTracker.enableLinkTracking();</xsl:text>
<xsl:text>
}
catch( err ) {
}
</xsl:text>
</script>
</xsl:if>