Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-11686

Update Google analytics code to the latest standard Google recomends

      ... or maybe even better allow adding code manually. Right now the recommendation are:

      Copy the following code, then paste it onto every page you want to track immediately before the closing </head> tag.

      Single domain

      <script type="text/javascript">
      
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-XXX-X']);
        _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>
      

      Domain with subdomains

      <script type="text/javascript">
      
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-XXX-X']);
        _gaq.push(['_setDomainName', '.XXX.org']);
        _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>
      

      Multiple top-level domains

      <script type="text/javascript">
      
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-XXX-X']);
        _gaq.push(['_setDomainName', 'none']);
        _gaq.push(['_setAllowLinker', true]);
        _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>
      

          [JENKINS-11686] Update Google analytics code to the latest standard Google recomends

          redsolo added a comment - - edited

          Thanks for the info, I havent used GA that much. One question regarding sub-domains, should it have "_gaq.push(['_setAllowLinker', true]);" also? I saw it on the http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html page, but not sure if it should be there or not.

          redsolo added a comment - - edited Thanks for the info, I havent used GA that much. One question regarding sub-domains, should it have "_gaq.push( ['_setAllowLinker', true] );" also? I saw it on the http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html page, but not sure if it should be there or not.

          Code changed in jenkins
          User: Erik Ramfelt
          Path:
          src/main/resources/hudson/plugins/google/analytics/GoogleAnalyticsPageDecorator/footer.jelly
          src/main/resources/hudson/plugins/google/analytics/GoogleAnalyticsPageDecorator/header.jelly
          src/main/webapp/domainName.html
          src/test/java/hudson/plugins/google/analytics/FooterWebTest.java
          src/test/java/hudson/plugins/google/analytics/HeaderWebTest.java
          src/test/resources/hudson/plugins/google/analytics/FooterWebTest/GoogleAnalyticsChild/footer.jelly
          src/test/resources/hudson/plugins/google/analytics/FooterWebTest/testFooterContainsProfileWithDomainName/config.xml
          src/test/resources/hudson/plugins/google/analytics/FooterWebTest/testFooterContainsProfileWithDomainName/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml
          src/test/resources/hudson/plugins/google/analytics/FooterWebTest/testFooterContainsProfileWithinQuotation/config.xml
          src/test/resources/hudson/plugins/google/analytics/FooterWebTest/testFooterContainsProfileWithinQuotation/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/GoogleAnalyticsChild/footer.jelly
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testHeadElementContainsScript/config.xml
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testHeadElementContainsScript/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptContainsProfileWithinQuotation/config.xml
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptContainsProfileWithinQuotation/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptForDomain/config.xml
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptForDomain/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptForMultipleTopLevelDomains/config.xml
          src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptForMultipleTopLevelDomains/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml
          http://jenkins-ci.org/commit/googleanalytics-plugin/f6e67c5fe06a923af2eb6e6728044d9a62b0e149
          Log:
          JENKINS-11686 Updated google analytics code to use the asynchronous syntax

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Erik Ramfelt Path: src/main/resources/hudson/plugins/google/analytics/GoogleAnalyticsPageDecorator/footer.jelly src/main/resources/hudson/plugins/google/analytics/GoogleAnalyticsPageDecorator/header.jelly src/main/webapp/domainName.html src/test/java/hudson/plugins/google/analytics/FooterWebTest.java src/test/java/hudson/plugins/google/analytics/HeaderWebTest.java src/test/resources/hudson/plugins/google/analytics/FooterWebTest/GoogleAnalyticsChild/footer.jelly src/test/resources/hudson/plugins/google/analytics/FooterWebTest/testFooterContainsProfileWithDomainName/config.xml src/test/resources/hudson/plugins/google/analytics/FooterWebTest/testFooterContainsProfileWithDomainName/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml src/test/resources/hudson/plugins/google/analytics/FooterWebTest/testFooterContainsProfileWithinQuotation/config.xml src/test/resources/hudson/plugins/google/analytics/FooterWebTest/testFooterContainsProfileWithinQuotation/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/GoogleAnalyticsChild/footer.jelly src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testHeadElementContainsScript/config.xml src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testHeadElementContainsScript/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptContainsProfileWithinQuotation/config.xml src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptContainsProfileWithinQuotation/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptForDomain/config.xml src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptForDomain/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptForMultipleTopLevelDomains/config.xml src/test/resources/hudson/plugins/google/analytics/HeaderWebTest/testScriptForMultipleTopLevelDomains/hudson.plugins.google.analytics.GoogleAnalyticsPageDecorator.xml http://jenkins-ci.org/commit/googleanalytics-plugin/f6e67c5fe06a923af2eb6e6728044d9a62b0e149 Log: JENKINS-11686 Updated google analytics code to use the asynchronous syntax

          Yury Zaytsev added a comment -

          Hi,

          Thanks for looking into this! I think it shouldn't, as I copy-pasted these examples from my Google Analytics account. The documentation says:

          The _setAllowLinker() method directs the target site to read cookie data from the POST data rather than from the regular user session information. In this way, you can pass cookie data set on one domain to another and thereby retain the visitor session from your online store to your shopping cart.

          I guess that for single domain with subdomains, it creates a cookie that can also be read by subdomains, so it doesn't really make sense to also put it there... but it's not a definite expert opinion on the subject, just my take at it.

          Hope that helps,
          Z.

          Yury Zaytsev added a comment - Hi, Thanks for looking into this! I think it shouldn't, as I copy-pasted these examples from my Google Analytics account. The documentation says: The _setAllowLinker() method directs the target site to read cookie data from the POST data rather than from the regular user session information. In this way, you can pass cookie data set on one domain to another and thereby retain the visitor session from your online store to your shopping cart. I guess that for single domain with subdomains, it creates a cookie that can also be read by subdomains, so it doesn't really make sense to also put it there... but it's not a definite expert opinion on the subject, just my take at it. Hope that helps, Z.

          redsolo added a comment -

          Ok, thanks.. I will release this asap.

          redsolo added a comment - Ok, thanks.. I will release this asap.

            redsolo redsolo
            zaytsev Yury Zaytsev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: