james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r532380 - /james/project/trunk/maven-skin/src/main/resources/META-INF/maven/site.vm
Date Wed, 25 Apr 2007 15:07:26 GMT
Author: bago
Date: Wed Apr 25 08:07:25 2007
New Revision: 532380

URL: http://svn.apache.org/viewvc?view=rev&rev=532380
Log:
Add an "hack" to out custom skin's site.vm so that every download* page will have an additional
javascript to add google analytics tracking to file downloads.
Downloads *clicks* will now be tracked as if they where pages placed in the /downloads/ folder.

Modified:
    james/project/trunk/maven-skin/src/main/resources/META-INF/maven/site.vm

Modified: james/project/trunk/maven-skin/src/main/resources/META-INF/maven/site.vm
URL: http://svn.apache.org/viewvc/james/project/trunk/maven-skin/src/main/resources/META-INF/maven/site.vm?view=diff&rev=532380&r1=532379&r2=532380
==============================================================================
--- james/project/trunk/maven-skin/src/main/resources/META-INF/maven/site.vm (original)
+++ james/project/trunk/maven-skin/src/main/resources/META-INF/maven/site.vm Wed Apr 25 08:07:25
2007
@@ -336,5 +336,60 @@
       _uacct = "UA-1384591-1";
       urchinTracker();
     </script>
+    #if ( $currentFileName.toLowerCase().startsWith("download") )
+    <script type="text/javascript">
+    if (document.getElementsByTagName) { 
+      var hrefs = document.getElementsByTagName('a'); 
+      var extensions = ["gz","bz2","zip","jar","asc","sar"];
+      for (var l = 0; l < hrefs.length; l++) {
+        if (hrefs[l] != "") {
+          var path = hrefs[l].pathname;
+          var external = hrefs[l].hostname != location.host;
+          if (external) {
+            var splitted = path.split('.');
+            var ext = splitted[splitted.length-1];
+            for (var e = 0; e < extensions.length; e++) {
+              if (extensions[e] == ext) {
+                startListening(hrefs[l],"click",trackDownloads);
+              }
+    	}
+          }
+        }
+      } 
+    } 
+    
+    function startListening (obj,evnt,func) { 
+      if (obj.addEventListener) {
+        obj.addEventListener(evnt,func,false); 
+      } else if (obj.attachEvent) {
+        obj.attachEvent("on" + evnt,func); 
+      } 
+    } 
+    
+    function trackDownloads (evnt) { 
+      var lnk; 
+      if (evnt.srcElement) { 
+        var elmnt = evnt.srcElement; 
+        while (elmnt.tagName != "A") { 
+          var newelmnt = elmnt.parentNode; 
+          elmnt = newelmnt; 
+        } 
+        lnk = elmnt.hostname + "/" + elmnt.pathname + elmnt.search; 
+      } else { 
+        lnk = this.hostname + this.pathname + this.search; 
+      } 
+    
+      var pos = lnk.indexOf("/james/");
+      if (pos != -1) {
+        lnk = lnk.substr(pos+7);
+      }
+      lnk = "/downloads/"+lnk;
+    
+      if (typeof(urchinTracker) == "function") {
+        urchinTracker(lnk);
+      }
+    } 
+    </script>
+    #end
   </body>
 </html>



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message