// the find
philipwalton/analyticsjs-boilerplate
Examples and best practices for using analytics.js
A boilerplate for Google Analytics (analytics.js) setup with best practices baked in — error tracking, performance timing, custom dimensions, and multi-tracker support. It's a companion to a specific blog post by Philip Walton, a former Google engineer who knew this library better than almost anyone.
Tracks uncaught errors as GA events, which most implementations miss entirely. Includes pageload performance timing out of the box. Multi-tracker setup for testing against a second property is a genuinely useful pattern that saves debugging pain. Tests exist, which is rare for boilerplate repos.
Last pushed September 2017 — analytics.js itself is deprecated and replaced by GA4/gtag.js, so this is a dead end for any new project. The repo depends on the autotrack library which is also unmaintained. No documentation on migrating toward GA4. Stars are flattering given the author's reputation; the code itself hasn't moved in nearly a decade.