Ticket #8565 (closed enhancement: fixed)

Opened 8 years ago

Last modified 8 years ago

Add Hewlett Google Analytics to all pages

Reported by: kef Owned by: maxwell
Priority: high Milestone: Hot Fixes
Component: Content Viewing Version: Dev
Severity: major Keywords:
Cc: ew2, maxwell, jccooper System Area: Content Display
Primary Skill: JavaScript
Site URL:
Suppress email to reporter: no

Description

Add something like the following code to all cnx.org pages. This was sent to us by a Hewlett funded company, Lunametrics, that is collating analytics for all Hewlett funded sites. It includes their ga account code, a site-wide cnx.org code, and a third optional code we already use for Collaborative Statistics. In the near future, we will be allowing authors to add their own analytics code. The easiest way for authors to do that will be to put it in their profile and have it appear in published modules, which could mean that multi-authored modules would have mulitiple codes, but boy would that be nice for the authors. The latter is just something to keep in mind since this ticket only addresses the account codes shown below.

The following notes are from John Henson of Lunametrics and are also attached as a txt file:

** The following code exists on some pages of your site.  This code should be modified as follows:

Existing Code:

      <script src="http://www.google-analytics.com/ga.js" type="text/javascript">
      </script>
      <script type="text/javascript">
        if(typeof(_gat) == 'object')
        {
          var pageTracker = _gat._getTracker("UA-5153795-1");
          pageTracker._initData();
          pageTracker._trackPageview();
        }
      </script>

Replace with:

      <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
      </script>
      <script type="text/javascript">
        if(typeof(_gat) == 'object')
        {
          var pageTracker = _gat._getTracker("UA-5153795-1");
          pageTracker._setDomainName('cnx.org');
          pageTracker._setCookiePath('/content/');
          pageTracker._trackPageview();
        }
      </script>

      <script type="text/javascript">
try {
var benchmarkTracker = _gat._getTracker("UA-7903479-1");
benchmarkTracker._setDomainName('cnx.org');
benchmarkTracker._trackPageview();

var overallTracker = _gat._getTracker("UA-5033010-1");
overallTracker._setDomainName('cnx.org');
overallTracker._trackPageview();
} catch(err) {}</script>

** The following code should be added to ALL all *other* pages on the site. 

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript">
try {
var benchmarkTracker = _gat._getTracker("UA-7903479-1");
benchmarkTracker._setDomainName('cnx.org');
benchmarkTracker._trackPageview();

var overallTracker = _gat._getTracker("UA-5033010-1");
overallTracker._setDomainName('cnx.org');
overallTracker._trackPageview();
} catch(err) {}</script>

Attachments

GATC.txt (2.0 KB) - added by kef 8 years ago.

Change History

Changed 8 years ago by kef

Changed 8 years ago by ew2

  • status changed from new to assigned

Changed 8 years ago by maxwell

  • status changed from assigned to working

Forgot to tie in r27364 from the commit message.

Changed 8 years ago by maxwell

(In [27365]) Adding Google analytics code to collection view for Hewlett use. Refs #8565

Changed 8 years ago by maxwell

(In [27366]) Adding Google analytics code to EIP help pages for Hewlett use. Refs #8565

Changed 8 years ago by maxwell

(In [27367]) Adding Google analytics code to custom collection view for Hewlett use. Refs #8565

Changed 8 years ago by maxwell

(In [27368]) Adding Google analytics code to metadata pages for Hewlett use. Refs #8565

Changed 8 years ago by maxwell

(In [27369]) Making a branch for Hewlett's site-wide Google Analytics Refs #8565

Changed 8 years ago by maxwell

(In [27371]) Making branch for Hewlett's site-wide Google Analytics Refs #8565

Changed 8 years ago by maxwell

(In [27374]) Adding Hewlett's Google Analytics code to the main site pages, if it should be there (CNX) and don't if it shouldn't (Rhaptos). Refs #8565

Changed 8 years ago by maxwell

  • status changed from working to testing

I believe this is done, so I'll put it in testing, even though I'm not sure there's any great way to test it, except to make sure it doesn't break other things and hope that it works.

Changed 8 years ago by jenn

  • skills changed from Unspecified to JavaScript
  • status changed from testing to closed
  • resolution set to fixed
  • area changed from Unknown to Content Display

Rolled out, and not causing viewing problems that I know of, though I'm not happy with the results I'm seeing so far. I'm holding off further testing today to see if the other half of my tests from yesterday show up tomorrow....

Note: See TracTickets for help on using tickets.