GTag-GA
A small ES module that loads Google Analytics 4 into a web page and sends page views and events through it. One import, one configuration call, and no dependencies.
About this project
GTag-GA adds Google Analytics 4 to a web page through the official gtag.js interface, packaged as an ES module. One import and one call with a measurement ID load gtag.js into the page, and tracking is live.
The API is the gtag API rather than a vocabulary of its own: the initialising call takes the measurement ID and an optional configuration object, and the event call takes the same arguments the official documentation shows, so anything written about gtag.js applies directly here.
The package has zero dependencies, ships TypeScript declarations and follows current Google Analytics 4 behaviour. It runs in the browser, because it adds the gtag.js script to the page itself, so in a server-rendered application the initialising call belongs in code that runs on the client. It is a few kilobytes for the one job of getting a page view or an event to Google Analytics without a tag manager in between.
Features
TypeScript types
No dependencies
