Closed Bug 1439650 Opened 6 years ago Closed 6 years ago

Track all AJAX requests in Google Analytics


(Webtools Graveyard :: Pontoon, enhancement, P3)



(Not tracked)



(Reporter: jotes, Assigned: jotes, Mentored)



(2 files)

Currently, Pontoon slowly prepares to embrace changes related to "".

And because of that, We have to understand the impact of every change during the process of transition. That requires more meaningful metrics, which don't exist.

We already use GA for tracking page views.

So, this seems to be low-hanging fruit to just track all AJAX requests (possibly transform them into the more readable form) and display them in GA dashboards.
So, it looks like Pontoon uses the old version (2013) of Google Analytics API (ga.js) and the current docs suggest to migrate to analytics.js.

Reference doc (look at the top of the page):

I'll investigate how hard it will be to make the migration - I don't want to derail into stuff that won't bring us the metrics but also I don't want to write obsolete code.
So, the next step is to decide what the structure of events we want to store in Google Analytics.

I think there are 2 possible solutions:

1. (small patch) Log all Ajax requests as one type of an event e.g.
  event: 'ajaxRequest',
  method: 'POST|GET'
  params: {
    requestTime: 1
2. (medium-size patch) Create separate events per every Ajax call just to avoid too much traffic and get more readability in dashboards.
I did the initial analysis, there are 29 possible events which could be extracted from the current AJAX calls.


In both cases, The code have to remove security sensitive stuff like e.g. csrf-related parameters.

:Phlax, :Pike
Could you help me with the decision about the next steps?
Flags: needinfo?(ryan)
Flags: needinfo?(l10n)
talking in real life, I guess we're good with target url of the xhr plus referrer, i.e., current url. Anonymized data in that URL, too.
Flags: needinfo?(l10n)
Commit pushed to master at
Bug 1439650 - Migrate to analytics.js (#863)

* Create a template for Google Analytics snippet and point to it in base templates
* Update the inline js snippet
* Update related CSP hashes and update CSP Rules
Assignee: nobody → poke
Follow-up about our discussion about mismatched metrics between New Relic and Google Analytics:

I discovered that We don't track page views for The Translate View correctly.

Currently, Pontoon sends an pageView event to Google Analytics once per every user session with The Translate View.
This approach works only for normal webpages, not single page apps.

New Relic is a backend and tracks every request from a user session. I feel in that state those numbers aren't comparable even in larger scale.

My hypothesis:
So, New Relic will always have equal or greater amount of events because it tracks the whole session.
The disproportion between New Relic and GA can be caused by users which spend more time during their sessions with The Translate View.

My suggestion:

We start tracking every change to an url inside The Translate View, that number feels more comparable to the amount of traffic from New Relic logs.

After that, We can investigate other possible things that can affect that analytics. Such as:

* Adblockers
* Javascript Bugs
* Less supported Browsers
* Changes done in Pontoon code during different periods of the time.

Is it okay for you?
Flags: needinfo?(l10n)
Flags: needinfo?(l10n)
Commit pushed to master at
Fix bug 1439650 - Track performance of all Ajax requests in Google Analytics. (#878)

* Add start time to every ajax request.
* Send event to Google Analytics with the overall time of request and requested url.
Closed: 6 years ago
Resolution: --- → FIXED
Priority: -- → P3
Flags: needinfo?(ryan)
Product: Webtools → Webtools Graveyard
You need to log in before you can comment on or make changes to this bug.