mr-gtag
Easy, strong typed, and a modern way to use google analytics gtag lib.
Both umd and es bundles are produced, along with type definitions.
Install
npm i mr-gtag
Usage
First, calling installGtag
injects the lib:
; installGtagtrackingId;
This injects the lib and then calls what is equivalent to gtag('config', trackingId, ...);
.
Some options are available here:
; installGtagtrackingId, ;
From here on, use any of the gtag functions available.
Send an event:
; gtag'event', 'page_view', ;
Refer to the google docs for more info and to see the different kinds of events you can send.
Release notes
2.0.0
- BREAKING CHANGE: Options that
installGtag
accepts were renamed to be the exact same as the gtag ones. Be sure to update those. - We now correctly handle registering more than one tracking id.