3 Replies Latest reply on May 12, 2011 12:44 PM by Fericit Bostan

    Getting Google Analytics to work

    Fericit Bostan Newbie

      I'm working with RichFaces 4 and I'm having trouble getting google analytics to work correctly. I've followed the documentation provided here:

      http://www.google.com/support/analytics/bin/answer.py?answer=174090

       

      but it still doesn't seem to load. I've read Nick's comments on this thread: http://community.jboss.org/message/59498

      but I unfortunately don't quite understand it.

       

      My page is as follows:

       

        <h:head>

        <h:outputStylesheet library="css" name="style.css" target="head" /> 

       

              <a4j:outputPanel ajaxRendered="true">

        <script type="text/javascript"> 

       

        var gaAccountID = '<h:outputText value="#{gaAccountID}" />';

        var gaRootDomain = '<h:outputText value="#{gaRootDomain}" />'

       

                           var _gaq = _gaq || [];

               _gaq.push(['_setAccount', gaAccountID]);

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

               _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);

               })();

        </script>

        </a4j:outputPanel> 

        </h:head>


      I know I am missing something simple based upon the google documentation but I can't seem to figure out what it is. I can see all of my variables getting properly expanded and assigned but I can't seem to get the script to execute.

       

      Thanks for the assistance.

        • 1. Getting Google Analytics to work
          Mark Paluch Master

          there is a missing semicolon after

          var gaRootDomain = '<h:outputText value="#{gaRootDomain}" />'

          • 2. Re: Getting Google Analytics to work
            Fericit Bostan Newbie

            Good catch. I added the ; but still google analytics does not seem to load.

             

            Here is what my javascript looks like after the page loads:

             

            <script type="text/javascript">

            //<![CDATA[

             

             

                    var gaAccountID = 'UA-1868359-1';

                    var gaRootDomain = '.intraxusa.com'

                    var gaApplicantConversionID = '1069446817';

                    var gaApplicantConversionLabel = 'Er2rCKO8QxCh7fn9Aw';     

                    var documentDomain = 'intraxusa.com';

             

                    var _gaq = _gaq || [];

                    _gaq.push(['_setAccount', gaAccountID]);

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

                    _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);

                    })();  

             

             

            //]]>

            </script>

            • 3. Getting Google Analytics to work
              Fericit Bostan Newbie

              Just to bring closure to this issue, it seems that it was working all along. I was basing my assumption of it not working on the use of a plugin named ghostery, which shows all tracking software on a page. It showed no results on my page when I rendered it in Safari, but when I launched my page in Chrome or FireFox it did show that my page was correctly tracking. I'm not certain for the

              discrepancy, but it appears that I had no issue after all.

               

              Thanks for enduring my ordeal and assisting me.