Closed boffbowsh closed 7 years ago
This is just a spike for now to capture some data. GA isn't useful enough for performance analysts to effectively measure the success of Q1, especially where content is concerned. We need to be able to match page views to actual content items, and also have the raw performance data, not sampled. Proposal https://docs.google.com/document/d/1Tw1gG_M08jAj1lXdq1vzdozxXGvbTU_SOjGXnxFAhcs/edit#
Looks like our other trackers have specific functions, so for this I wonder if we should break this up to have a.
'real-user-measurement-tracker' etc.
The other modules are plugins, whereas this is a Tracker that is compatible with the GOVUK.GoogleAnalyticsUniversalTracker
api, so can be used with GOVUK.Analytics
. So I'm not sure it's the same thing.
I wonder how the image loading would affect users leaving the page, eg clicking external links or download links that get tracked as events. I don't expect it to block, but it's a risk we need to check.
Presumably we are using a GIF rather than https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon because of current browser support?
We could try sendBeacon
and fall back to the img
tag if the browser doesn't support it? But also, this is just meant to be a spike to get some representative data. It doesn't yet need to be 100% complete in this iteration.
Specs added, ready for another review. Still todo, add the screen resolutions
Screen measurements added
@boffbowsh Could you include a test that makes multiple calls? Do you have an example of the network calls this makes when run on a page?
I think I'll have to change sendBeacon
to a $.get
only - nginx won't support POST
to the empty_gif
endpoint.
This is ready to go again now. I'll get it on integration again for final testing. Here's a HAR file as an example, viewable with http://www.softwareishard.com/har/viewer/. www.dev.gov.uk.har.zip
Related: https://github.com/addyosmani/timing.js/ (We need to test this cross browser)
I'd like to get this live to start collecting some data, and test its usefulness. Can I get another review please @tomnatt / @nickcolley ?
FWIW my analysis of the performance implications (throttled to a 3g connection):
Now awaiting a FEDEV to tell me I'm completely wrong 😃
@nickcolley can you comment/approve please?
We're going to review this in three weeks as part of the two week blitz, for now we'll get this in so we can test the kind of data we're getting back.
In the future I think this probably should belong in Static and we should address the issues with cross browser APIs
This has a similar API to the GA tracker module so it’s compatible with the
GOVUK.Analytics
module. It sends data to the server by adding animg
tag for an empty gif with the payload data encoded in the querystring of thesrc
. This data will be picked up from the CDN logs.It adds some additional data that the main GA tracker doesn’t add, such as performance information and the GA client ID. This is because it’s assumed that GA sends similar things by default anyway.
This data will be used alongside regular exports of content metadata to provide performance analysts with more reliable content-focused analytics data.
This is for review only at the moment to check my approach is reasonable.
TODO: