Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

The full documentation of gathering statistics using Google Analytics for uPortal 3.2.x can be found here: Google Analytics

Sacramento State implemented the following steps of the original documentation for their environment:

Step 1: Add the following java class file

  • The attached java class, GoogleSessionThemeParameter, below needs to be added to the following location: ../uportal-impl/src/main/java/org/jasig/portal/layout/dlm/providers

This java class file will be now be located alongside the other theme processors.

Step 2: Add parameters (optional)

Sacramento State chose not to track parameters such as affiliations so this step was skipped.

Step 3: Add google analytics code

  1. Edit universality.xsl (../uportal-war/src/main/resources/layout/theme/universality/universality.xsl)
  2. Add the two following template code snippets, "page.js" and "tracking-action", to universality.xsl

This section sets up asynchronous google analytics tracking.  The "page.js" template puts the script at the top of every generated page in the head element.

These snippets were added to universality.xsl:
universality.xsl
<xsl:template name="page.js">
	<script type="text/javascript">
		<xsl:choose>
			<xsl:when test="$serverEnv='my.uchicago.edu'">
				var env = "<xsl:value-of select="$serverEnv" />";
				var gaAcct = "*************";
			</xsl:when>

			<xsl:when test="$serverEnv='mystage.uchicago.edu'">
				var env = "<xsl:value-of select="$serverEnv" />";
				var gaAcct = "*************";
			</xsl:when>

			<xsl:otherwise>
				var env = "<xsl:value-of select="$serverEnv" />";
				var gaAcct = "*************";
			</xsl:otherwise>
		</xsl:choose>

		var _gaq = _gaq || [];
		_gaq.push(['_setAccount', gaAcct]);

 		_gaq.push(['_setDomainName', env]);

 		_gaq.push(['_trackPageview']); 
	  </script>
</xsl:template>
 
<xsl:template name="tracking-action">
          <script type="text/javascript">	 
               (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'; 
                  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
               })();
          </script>
</xsl:template>

 

Step 4: Add tracking

Once the tracking api is loaded, we place tracking code on any of the user initiated events we want to track during their session.

For example, in the sections below we are tracking these events: portlet minimize, portlet maximize, portlet removed, change portlet tab, add content, add tab and customize tab layout.

The following was added to components.xsl (uportal-war/src/main/resources/layout/theme/universality/components.xsl)

components.xsl
<a id="contentDialogLink" onclick="_gaq.push(['_trackEvent', 'gaAcct','ADD CONTENT']);" href="javascript:;"
    	title="{$TOKEN[@name='PREFERENCES_LINK_ADD_CONTENT_LONG_LABEL']}">
    	<span><xsl:value-of select="$TOKEN[@name='PREFERENCES_LINK_ADD_CONTENT_LABEL']"/></span>
</a>


...

<a id="layoutDialogLink" onclick="_gaq.push(['_trackEvent', 'gaAcct','TAB LAYOUT']);" href="javascript:;"
   	title="{$TOKEN[@name='PREFERENCES_LINK_LAYOUT_LONG_LABEL']}">
    	<span><xsl:value-of select="$TOKEN[@name='PREFERENCES_LINK_LAYOUT_LABEL']"/></span>
</a>

...

<a id="addTabLink" onclick="_gaq.push(['_trackEvent', 'gaAcct','ADD TAB']);" href="javascript:;"
                    title="{$TOKEN[@name='PREFERENCES_LINK_ADD_TAB_LONG_LABEL']}">
                   <span><xsl:value-of select="$TOKEN[@name='PREFERENCES_LINK_ADD_TAB_LABEL']"/></span>
</a>

 

 

 

 

Additional References

 

Having problems with these instructions?

Please send us feedback at uportal-user@lists.ja-sig.org

  • No labels