Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Create simplest download and external link tracking plugins #208
This is a minimum viable tracker. It will work as expected in Chrome and Firefox – browsers that support
A fully-formed tracker would include, in older browsers, a means of preventing the page from loading until an event has been successfully tracked. This degrades the user experience and the complexities introduce a greater risk of links not working. The data collected from this tracker will provide much needed context and visibility.
Before merging, I'd love to get some feedback on this approach. Particularly:
The simplest approach to external link tracking, using Google Analytics `sendBeacon` support to guarantee the event is captured when supported. When not supported, the event will fire and a proportion of those events will make it to analytics. The dataset will be incomplete. Add support for setting the transport option to Universal Tracker
The simplest approach to download tracking, using Google Analytics `sendBeacon` support to guarantee the pageview is captured when supported. When not supported, the pageview will fire and a proportion of those events will make it to analytics. The dataset will be incomplete. Includes adding support for setting the transport option when tracking page views.
If an element, eg an image, is clicked within a link, evt.target returns the image rather than the link. This leads to an incorrect event/pageview being tracked, or no tracking at all. * Stop link clicks from loading a page using an HTML click handler * Traverse DOM when event target is not a link
I don't know if using the file extension is a sensible way to decide if something is an attachment.
For GOV.UK we have two distinct attachment URLs:
Given that those are both specific to us rather than applicable to the toolkit, would it be worth making the marchers configurable and passing them in via static? That would make this solution more generally applicable but also more accurate to our use cases.
Add tracking to all external links (any link beginning with http and not linking to the current host) Based on https://github.com/alphagov/govuk_frontend_toolkit/blob/master/javascrip ts/govuk/analytics/external-link-tracker.js * Simplified to remove custom dimensions and to work with GOVUKAdmin analytics lib * alphagov/govuk_frontend_toolkit#208