Implement Google Analytics on wiki.mozilla.org

RESOLVED FIXED

Status

Websites
Web Analytics
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: cmore, Unassigned)

Tracking

unspecified
x86
Mac OS X
Dependency tree / graph
Bug Flags:
sec-review +

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
Full website address: wiki.mozilla.org

Goal: Learn how people are using the wiki, what browsers are accessing it, and how it can be improved.

Users: cmore@mozilla.com, jcrawford@mozilla.com, jbertsch@mozilla.com
(Reporter)

Comment 1

5 years ago
Please add this code to the php's template at the bottom of the closing </head>. This does not good in the Footer like the old GA code. This goes in the <head>.

<script type="text/javascript">

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

Comment 2

5 years ago
Google has been emailed to enable premium.
Submitted a pull request including this code for the _upgraded_ theme: https://github.com/mozilla/mediawiki-skins-gmo/pull/1
(Reporter)

Comment 4

5 years ago
(In reply to Justin Crawford [:hoosteeno] from comment #3)
> Submitted a pull request including this code for the _upgraded_ theme:
> https://github.com/mozilla/mediawiki-skins-gmo/pull/1

+1 :)
(Reporter)

Updated

5 years ago
Assignee: nobody → hoosteeno
(Reporter)

Comment 5

5 years ago
:hoosteeno: any idea what IT's timeline is for the mediawiki upgrade and when your PR would be merged and pushed to prod? Is it possible to get this change in the current mediawiki pre-upgrade so we can get some data now?
It is unlikely that new theme code will be deployed to the current version of mediawiki. IT's timeline for upgrading is constrained by resource scarcity, but continues to be Q1. 

The new version is deployed here:

https://wiki-dev.allizom.org

The next step is to test it. See dependent bug for more info.
Depends on: 707181
(Reporter)

Comment 7

5 years ago
I don't mean deploying new theme code to mediawiki now. I mean just simply copy/pasting the GA code from comment 0 to the base php template on wiki-dev. It is just one copy/paste into the template and won't require any new theme code.

It can be added to the template or to this file:

/skins/common/wikibits.js
The wiki will be upgraded very shortly, and this should wait for that. The patch in comment 3 is probably the best way to implement, since using the GA extension on SMW may require a security review.

Will work with IT to get GA code into new theme on new wiki after upgrade. 

cc'ing solarce, hexmode, jd on this bug.
Howdy, any chance we could push GA to the wiki sometime soon? There's a PR for it in comment 3.

Comment 10

5 years ago
I think that adding this directly to the theme may be the wrong approach. I say this as the base code is used by two themes (a third under sec review). This theme (and underlying code) are used by a good number of sites, some of which are confidential in nature. As I understand the patch below it would then apply to all of these sites and not just the one targeted here.

I will go ahead and set the sec review flag, and I imagine that this might be a somewhat painless process as the extension in question is really just a 67 line php script.

If anyone has objections to this approach or has additional information please let me know.

For reference the extension page is:
http://www.mediawiki.org/wiki/Extension:Google_Analytics_Integration

For reference the code is:
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/googleAnalytics.git;a=tree
Flags: sec-review?
(Reporter)

Comment 11

5 years ago
An extension is a good idea and should be a straightforward review. Thanks!
Flags: sec-review? → sec-review?(fbraun)
Easy review, little code. All good! :)
Flags: sec-review?(fbraun) → sec-review+
(Reporter)

Comment 13

5 years ago
(In reply to Frederik Braun [:freddyb] from comment #12)
> Easy review, little code. All good! :)

Great!

:jd for the config:

$wgGoogleAnalyticsAccount = "UA-xxxxxxx-x";

The account is UA-35433268-22.

Comment 14

5 years ago
This has been deployed on wiki-dev.allizom.org

Once you are satisfied that everything is working as expected then ping me on IRC and I will push it to stage then prod.
(Reporter)

Comment 15

5 years ago
(In reply to Jason Crowe [:jd] from comment #14)
> This has been deployed on wiki-dev.allizom.org
> 
> Once you are satisfied that everything is working as expected then ping me
> on IRC and I will push it to stage then prod.

I do not see any GA code in wiki-dev.allizom.org or any GA requests firing off. Is there any cache that needs to be purged?

Comment 16

5 years ago
If you view:

https://wiki-dev.allizom.org/Special:Version

You will see that GA is installed and the version number shows up.

I even tried placing the $wgGoogleAnalyticsAccount variable directly in the extension code file to no avail.

So the module loads correctly, there are no errors generated (you cannot be logged in as a SysOp FYI) while &debug=1. In fact it does not even try to load the ga.js file. Now according to the code this file should come from 'google-analytics.com/ga.js'. This loads for me so I can only assume it will load for other clients. Further none of the three error messages (lines 43, 47, 51) are included in the code or logs.

This all leads me to think that the error might be here on line 35:
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/googleAnalytics.git;a=blob;f=googleAnalytics.php;h=757ea0297c4e17c48f282ecd8dc0fc46d2f8554b;hb=refs/heads/REL1_19#l35

I only think that because it says "$skin" which has traditionally lead to issues (we had an unmaintained theme for many a year). Fortunately we have a hero who has come to our rescue... <enter hexmode> ... Applause and cheers are heard from the crowd!

In all seriousness I have no idea why this is not working, hopefully hex has a free moment to provide sage advice.

Oh and there is no front end cache on dev.
(Reporter)

Comment 17

5 years ago
Ok, it could be our skin that is not include widgets like this in the rendering of the template. We do want to get the skin updated to Mozilla Sandstone and maybe if hacking the old skin is problematic, we make the bigger leap to sandstone.
Flags: needinfo?(mah)
(Reporter)

Comment 18

5 years ago
Any update here? Anything we can do to help out?
There's a wikimo theme for sandstone currently in secreview: bug 793403. I will reach out to that team to see if they can include GA.
(In reply to Chris More [:cmore] from comment #17)
> We do want to get the skin updated to Mozilla
> Sandstone and maybe if hacking the old skin is problematic, we make the
> bigger leap to sandstone.

I will have time to work on this after the 23rd of this month.
Flags: needinfo?(mah)
(Reporter)

Comment 21

5 years ago
(In reply to Mark A. Hershberger (hexmode) from comment #20)
> (In reply to Chris More [:cmore] from comment #17)
> > We do want to get the skin updated to Mozilla
> > Sandstone and maybe if hacking the old skin is problematic, we make the
> > bigger leap to sandstone.
> 
> I will have time to work on this after the 23rd of this month.

Is the estimation for when this could land in the next two weeks? Thanks!
I would like a copy of LocalSettings.php (with passwords removed, natch) so I can figure this out ... The copy of LocalSettings.php that I have does not have anything with GoogleAnalytics in it.

Updated

5 years ago
Duplicate of this bug: 877845
We would like to propose a new front page for the wiki, and to do so we need to know what is popular. I am travelling to SF to work on this with dboswell in the last week in June, and it would be good to have a couple of weeks of analytics by then.

Can this work be accelerated? If not, is there any way we can hack the GA code into the existing wiki codebase, now its been upgraded?

Rough estimates will do for this task, so I don't mind too much if it's only in the default theme. 

Gerv
Assignee: hoosteeno → nobody
(In reply to Gervase Markham [:gerv] from comment #24)
> Can this work be accelerated?

I think this will take me less than 4 hours, so I can find time to do that this weekend.  Frankly, it should only take about an hour, but I'm being generous.

I'm putting this item at the top of the list for wikimo work since the other item that had any urgency (Bug #856021) doesn't seem to have any movement towards resolution -- since I'm depending on a response from Operations.

Updated

5 years ago
Blocks: 877742
Created attachment 757703 [details] [diff] [review]
patch to fix missing ga code

The GA code isn't being added because I screwed up on the skin.  If you look at the html for the default skin, you'll see it is missing the ending tags.

I wish I had seen this earlier, but the attached patch should fix this.

fwiw, this looks like it may solve some problems with the MW-Bugzilla extension, too.
This is now on wiki-dev. https://wiki-dev.allizom.org  Close when in prod?

Comment 28

5 years ago
I pushed the fix to stage and then prod now.

Let me know if there are any issues.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
confirmed that the code is there in prod.  Still waiting on feedback from the original requesters.
Awesome :-) Where and when will we be able to see data from this?

Gerv

Comment 31

5 years ago
(In reply to Gervase Markham [:gerv] from comment #30)
> Awesome :-) Where and when will we be able to see data from this?
> 
> Gerv
Flags: needinfo?(chrismore.bugzilla)
(Reporter)

Comment 32

5 years ago
Thanks! Verified that I can see GA traffic on prod.
Flags: needinfo?(chrismore.bugzilla)
(Reporter)

Comment 33

5 years ago
(In reply to Gervase Markham [:gerv] from comment #30)
> Awesome :-) Where and when will we be able to see data from this?
> 
> Gerv

I just added you to GA and this profile. Log in with gerv@mozilla.org.

Comment 34

5 years ago
cmore, could you add wiki.mozilla.org to my GA account too please?  Thanks.
(Reporter)

Comment 35

5 years ago
(In reply to David Boswell from comment #34)
> cmore, could you add wiki.mozilla.org to my GA account too please?  Thanks.

done!
You need to log in before you can comment on or make changes to this bug.