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

Update Google analytics code to the latest standard Google recomends

    Details

    • Similar Issues:

      Description

      ... 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>
      

        Attachments

          Activity

          Hide
          redsolo 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.

          Show
          redsolo 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.
          Hide
          scm_issue_link 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

          Show
          scm_issue_link 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
          Hide
          zaytsev 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.

          Show
          zaytsev 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.
          Hide
          redsolo redsolo added a comment -

          Ok, thanks.. I will release this asap.

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: