Friday, January 30, 2015

Custom analytics in Alfresco Share

Other than using Google Analytics for tracking for Alfresco Share for tracking analytics, one easy way to create a custom one is to have a js file that will be called for any share page being accessed.

  1. Make two js files, custom-analytics.js and custom-analytics-min.js, save these under custom-share-amp\src\main\amp\web\js. Put in alert("custom-analytics file!") in there for now to test that the js is being called. You need both the regular and the –min file for running share in either regular or debug mode.
  2. Make a copy of the custom-share-amp\target\share-war\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\head\resources.get.html.ftl file.  The copy should go into the extensions folder, so the extension ftl will be used custom-share-amp\src\main\amp\config\alfresco\web-extension\site-webscripts\org\alfresco\components\head 
  3. Under share-resources section, add a reference to the custom-analytics.js file:
    <@markup id="shareResources">
    <@script type="text/javascript" src="${url.context}/res/js/custom-analytics.js" group="template-common"/>
  4. Redeploy share (or copy over and refresh share webscripts), when you click on any link in share, the javascript alert should pop up.

No comments:

Post a Comment

I appreciate your time in leaving a comment!