Closed Bug 818195 Opened 12 years ago Closed 11 years ago

Add Google Analytics to Bedrock/PHP templates for www.mozilla.org

Categories

(www.mozilla.org :: Analytics, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED
Future

People

(Reporter: cmore, Assigned: sancus)

References

Details

(Whiteboard: [u=admin c=google-analytics p=1] b=trunk r=111424)

Attachments

(3 files)

We need to add Google Analytics to www.mozilla.org and I would like to use the following process. We are going to start with standard tracking before adding click tracking.

Note: The code should be added just before the closing </head>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-36116321-1']);
  _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>

1) Add Google Analytics code snippet to PHP header templates. We could add a new googleanalytics.js include file to each of the include files below and then add the code to it so that we don't have to add the code to 4 different locations in PHP.

http://viewvc.svn.mozilla.org/vc/projects/mozilla.com/trunk/includes/header.inc.php?view=markup

http://viewvc.svn.mozilla.org/vc/projects/mozilla.com/trunk/includes/header-portal-pages.inc.php?view=markup

http://viewvc.svn.mozilla.org/vc/projects/mozilla.com/trunk/includes/mobile-header-en-US.inc.php?view=markup

http://viewvc.svn.mozilla.org/vc/projects/mozilla.com/trunk/includes/mobile-header-l10n.inc.php?view=markup

2) Add Google Analytics code to Bedrock template:

https://github.com/mozilla/bedrock/blob/master/templates/base.html

https://github.com/mozilla/bedrock/blob/master/templates/base-resp.html

Again, both on the PHP side and Bedrock side, it should be added to just above the closing </head>

After we get this on -dev, I can scan the servers from HTTP to see if we have site-side coverage on all pages that have Webtrends.
Target Milestone: --- → Future
Whiteboard: [u=admin c=google-analytics p=1]
Blocks: 793287
No longer blocks: 793287
OS: Mac OS X → All
Hardware: x86 → All
Blocks: 809622
Assignee: nobody → mkelly
Bedrock PR is at https://github.com/mozilla/bedrock/pull/519 (It passed!). Attaching PHP-side diff for review.

Once that passes I'll file IT bugs to add the tracking codes to stage and prod settings, and then push the changes out for testing.

Chris: Will stephend be handling testing this?
Attachment #689263 - Flags: review?(sancus)
Flags: needinfo?(chrismore.bugzilla)
Comment on attachment 689263 [details] [diff] [review]
Patch for adding Google Analytics to mozilla.com

Looks fine, r+
Attachment #689263 - Flags: review?(sancus) → review+
Commit pushed to master at https://github.com/mozilla/bedrock

https://github.com/mozilla/bedrock/commit/2cd416fb79901381f493c3d02fafe5600c5a1360
Bug 818195: Add Google Analytics tracking code to base templates.
Commited to trunk in r111396, to stage in r111397. 

This appears to be working on stage. Once cmore gives the go ahead we'll update the settings on prod and push.
Flags: needinfo?(chrismore.bugzilla)
I have an update to the Google Analytics code snippet to enable in-page analysis:

<script type="text/javascript">

  var _gaq = _gaq || [];
  var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
  _gaq.push(['_require', 'inpage_linkid', pluginUrl]);

  _gaq.push(['_setAccount', 'UA-36116321-1']);

  _gaq.push(['_setDomainName', 'mozilla.org']); 
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_setAllowAnchor', 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>


We needed to add some additional attribute and the only variable in there should be the account number that you have tracked in the settings file.
Commit pushed to master at https://github.com/mozilla/bedrock

https://github.com/mozilla/bedrock/commit/273ee53b7c30ab1936b78694d322cc4569794558
Bug 818195: Add in-page analysis configuration to Google Analytics.
Updates commited to trunk in r111404 and stage in r111405.
I can currently running my scanner on stage and will report the results. I am looking to see if we have GA on all pages we have WT.
*Most* of the pages in this file are probably because the tags are missing on the legacy moz.org templates.
(In reply to Chris More [:cmore] from comment #9)
> *Most* of the pages in this file are probably because the tags are missing
> on the legacy moz.org templates.

Looking through the file, it looks like this is correct; most of the pages I saw or checked were mozilla.org pages. sancus has already said that he'll take care of these pages, so I suggest we go ahead with the intial deploy and re-run the script after sancus' changes to see if we missed anything.
I am able to see the traffic in Google Analytics and I created filters for each of the profiles so that the demo, stage, and dev, will all be reported separately. I am fine release this in stages as soon as possible. Thanks!
Commited to production in r111422. Pushed bedrock live also. Yay!
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Mkelly:

You have the wrong Google Analytics code on the site! It is not wrong, but the order of the variables it in correct. You should have copy/pasted the code from comment 5 instead of just adding just adding the changes. There were also new variables that you didn't add to the code snippet.

Again, it should be exactly:

<script type="text/javascript">

  var _gaq = _gaq || [];
  var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
  _gaq.push(['_require', 'inpage_linkid', pluginUrl]);

  _gaq.push(['_setAccount', 'UA-36116321-1']);

  _gaq.push(['_setDomainName', 'mozilla.org']); 
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_setAllowAnchor', 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>
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Edit: the order of the variable is NOT correct. The code above is what it should be minus the variable for the account number on the php and python side.
Whiteboard: [u=admin c=google-analytics p=1] → [u=admin c=google-analytics p=1] b=trunk r=111424
Commits pushed to master at https://github.com/mozilla/bedrock

https://github.com/mozilla/bedrock/commit/007071bbe0dd8b31089d85c6ecd62e4a120717c3
Bug 818195: Fix google analytics variables.

https://github.com/mozilla/bedrock/commit/38ae8e3617682d0fcbe740e05333437d6e00c908
Merge pull request #522 from pmclanahan/bug-818195-fix-google-analytics

Bug 818195: Fix google analytics variables.
Fixed and pushed to prod on bedrock and PHP sides.
Status: REOPENED → RESOLVED
Closed: 12 years ago12 years ago
Resolution: --- → FIXED
Let's keep this open until Sancus can get his changes on the legacy mozilla.org side. We are still missing about 750+ pages that don't have GA tracking.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee: mkelly → sancus
This should already be fixed for the community site, so check again. The Thunderbird section is going to take a bit longer, I was working on something else in the header files and there's already changes checked into staging that I don't want to push live just yet, so I need to finish that first.
OK, that should be done now. All pages should have this, apart from any stragglers that may exist without header files, so feel free to do another sweep and verify.
Status: REOPENED → RESOLVED
Closed: 12 years ago12 years ago
Resolution: --- → FIXED
It is missing on these URLs:

http://www.mozilla.org/en-US/thunderbird/organizations/

http://www.mozilla.org/en-US/thunderbird/organizations/faq/

http://www.mozilla.org/en-US/foundation/annualreport/2010/ (and sub pages)

http://www.mozilla.org/en-US/about/mozilla-spaces/

I can scan again once these are resolved.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
sancus is handling the rest of the URLs, but I've got a patch for the Mozilla Spaces page on the mozilla.com side. Asking for an r? because I'm not 100% sure how pascal's l10n system works.
Attachment #691535 - Flags: review?(sancus)
Comment on attachment 691535 [details] [diff] [review]
Patch for adding GA to spaces page

Yeah, I just noticed that none of the l10n pages would have google analytics code. The header-pages.inc.php line should fix that...at least on most pages.

So you decided not to add a header to the spaces page, then?
2010 annual report is fixed in r111558.
Thunderbird pages are fixed in r111541, live in r111557.

Note that for some of the TB pages, I put the GA code in the footer because they simply don't have header includes and there are a million copies of them in each of the l10n dirs that I didn't really feel like messing with to add header includes.
(In reply to Andrei Hajdukewycz [:sancus] from comment #22)
> So you decided not to add a header to the spaces page, then?

Yeah, just adding GA is good enough for this bug, and I'd rather not try and mess with the header on that page if it's not necessary.
sounds good. should we just close this now?
Attachment #691535 - Flags: review?(sancus) → review+
Merged the spaces and l10n page changes to trunk in r111622 and to stage in r111623. 

cmore, can you verify that https://www.allizom.org/en-US/about/mozilla-spaces/ is working with Google Analytics now? It's got the same code as the other pages, but the requests going to Google look a little different.
(In reply to Michael Kelly [:mkelly] from comment #26)
> Merged the spaces and l10n page changes to trunk in r111622 and to stage in
> r111623. 
> 
> cmore, can you verify that
> https://www.allizom.org/en-US/about/mozilla-spaces/ is working with Google
> Analytics now? It's got the same code as the other pages, but the requests
> going to Google look a little different.

All I see different in the code is that this:

  var prefix = ('https:' == document.location.protocol ? 'https://ssl' :
                  'http://www');

is on two lines as compared one line as in:

  var prefix = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www');
Status: REOPENED → RESOLVED
Closed: 12 years ago11 years ago
Resolution: --- → FIXED
(In reply to Michael Kelly [:mkelly] from comment #26)
> Merged the spaces and l10n page changes to trunk in r111622 and to stage in
> r111623. 
> 
> cmore, can you verify that
> https://www.allizom.org/en-US/about/mozilla-spaces/ is working with Google
> Analytics now? It's got the same code as the other pages, but the requests
> going to Google look a little different.

mkelly pmac: it appears truck revision r111622, never made it on to prod. 

Everything looks fine on dev/stage.

Thanks!
Assignee: sancus → pmac
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Sancus got this on to production. Thanks!
Assignee: pmac → sancus
Status: REOPENED → RESOLVED
Closed: 11 years ago11 years ago
Resolution: --- → FIXED
fixed. I see GA on PHP pages
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: