[Yanel-commits] rev 44471 - public/yanel/trunk/src/webapp/htdocs/Google-Analytics

guillaume at wyona.com guillaume at wyona.com
Fri Aug 28 13:38:18 CEST 2009


Author: guillaume
Date: 2009-08-28 13:38:18 +0200 (Fri, 28 Aug 2009)
New Revision: 44471

Modified:
   public/yanel/trunk/src/webapp/htdocs/Google-Analytics/GA.xslt
Log:
Google Analytics support: now always providing something actually ressembling a path
 for assets to the GA tracking function, thanks to a JS function that gets
 the fully-qualified URL from HTML "a" elements.

Issue: 7169


Modified: public/yanel/trunk/src/webapp/htdocs/Google-Analytics/GA.xslt
===================================================================
--- public/yanel/trunk/src/webapp/htdocs/Google-Analytics/GA.xslt	2009-08-28 10:30:23 UTC (rev 44470)
+++ public/yanel/trunk/src/webapp/htdocs/Google-Analytics/GA.xslt	2009-08-28 11:38:18 UTC (rev 44471)
@@ -57,6 +57,14 @@
 <script type="text/javascript"><xsl:text>
 var pageTracker = _gat._getTracker("</xsl:text><xsl:value-of select="$GA-key"/><xsl:text>");
 pageTracker._trackPageview();
+<!--TODO?(performance) move that into a separate JS file: -->
+function Yanel_requestURIFromFQURL(HTMLAelement) {
+  var FQURL = HTMLAelement.href<!--alert('FQURL: ' + FQURL);-->;
+  var i = FQURL.indexOf('://');<!--alert('i: ' + i);-->
+  i = FQURL.indexOf('/', i + 3);<!--alert('i: ' + i);-->
+  var filename = FQURL.substring(i);<!--alert('filename: ' + filename); return false;-->
+  return filename;
+}
 </xsl:text></script>
 </xsl:template>
 
@@ -66,11 +74,11 @@
   <xsl:copy>
     <xsl:apply-templates select="@*[name()!='onclick']"/>
     <xsl:attribute name="onclick">
-      <xsl:text>pageTracker._trackPageview(</xsl:text>
+      <xsl:text>pageTracker._trackPageview(<!----></xsl:text>
       <xsl:call-template name="yanel-xsl:GA-asset-filename-JSexpr-from-URL">
         <xsl:with-param name="URL" select="$URL"/>
       </xsl:call-template>
-      <xsl:text>);</xsl:text>
+      <xsl:text>)<!---->;</xsl:text>
       <xsl:value-of select="@onclick"/>
     </xsl:attribute>
     <xsl:apply-templates select="node()"/>
@@ -80,18 +88,8 @@
 
 <xsl:template name="yanel-xsl:GA-asset-filename-JSexpr-from-URL">
   <xsl:param name="URL"/>
-  <xsl:text>'</xsl:text>
-  <xsl:call-template name="yanel-xsl:GA-asset-filename-from-URL">
-    <xsl:with-param name="URL" select="$URL"/>
-  </xsl:call-template>
-  <xsl:text>'</xsl:text>
+  <xsl:text>Yanel_requestURIFromFQURL(this<!--, '</xsl:text><xsl:value-of select="$URL"/><xsl:text>'-->)</xsl:text>
 </xsl:template>
 
 
-<xsl:template name="yanel-xsl:GA-asset-filename-from-URL">
-  <xsl:param name="URL"/>
-  <xsl:value-of select="substring-after($URL, '://')"/><!--TODO: make it works with relative URLs as well!!! -->
-</xsl:template>
-
-
 </xsl:transform>



More information about the Yanel-commits mailing list