@moosesaeed/partytown-ga-gtag

0.0.12 • Public • Published

Global site tag (gtag.js) - Google Analytics

npm npm bundle size (minified)

ES module for the Google Analytics Global Site Tag.

Install

$ npm install --save ga-gtag

Usage

import { gtag, install } from 'ga-gtag';

// Substitute your tracking ID (begins with "G-", "UA-", "AW-" or "DC-")
install('G-##########'); 

install() adds the Global Site Tag script element into <head>. It only needs to be called once, but can safely be called multiple times (the script won't be re-added).

install() also has a second, optional argument that can be used to specify additional config info for the initialization (for instance to disable pageview measurement):

install('G-##########', { 'send_page_view': false });

From there, gtag() can be used as specified in Google's documentation:

gtag('event', 'login', { 'method': 'Google' });

Dependents (0)

Package Sidebar

Install

npm i @moosesaeed/partytown-ga-gtag

Weekly Downloads

2

Version

0.0.12

License

MIT

Unpacked Size

7.41 kB

Total Files

5

Last publish

Collaborators

  • moosesaeed