from Hacker News

Show HN: A tiny (400B) client-side module for tracking with Google Analytics

by lukeed on 7/27/17, 3:25 AM with 1 comments

  • by lukeed on 7/27/17, 3:25 AM

    Main takeaways:

    - 0.4kb vs 12kb for official client (gzip)

    - Respects visitors' `doNotTrack` settings

    - Does not ship internal XHR library

    - Correlates to the Google docs

    - API is 99% familiar, haha

    - Well-documented

    - Cacheable

    It isn't exactly a drop-in replacement, but the tweaks needed are incredibly minor.

    The GET requests are made via `new Image()`, which is a low priority network request, so your critical requests won't be blocked or delayed because of a trivial `pageview` analytic.

    Internet Explorer is not supported by default; however, it's VERY easy to regain compatibility. `Object.assign` is the only roadblock, which has a Babel quick-fix.

    Hope you enjoy! And feel free to ask questions. Thanks!