@blunck/ga

0.3.0 • Public • Published

@blunck/ga

Latest Version on NPM

Simple tool to add Google Analytics tracking code to your website

Installation

npm install @blunck/ga

Usage

import ga from '@blunck/ga'

// Add gtag.js script & initialize
ga.add('UA-XXXXXXXXX-X')

// Initialize without anonymizing ip address
ga.add('UA-XXXXXXXXX-X', false)

// Initialize with extra options
ga.add('UA-XXXXXXXXX-X', true, {
    page_path: '/home'
})

// Use window.gtag i.e. to send events
gtag('event', '<action>', {})

// Use window.gtagConfig to update configuration
gtagConfig({ 'page_path': '/search' })

// The previous example is short for:
gtag('config', 'UA-XXXXXXXXX-X', { 'page_path': '/search' })

Readme

Keywords

Package Sidebar

Install

npm i @blunck/ga

Weekly Downloads

2

Version

0.3.0

License

MIT

Unpacked Size

2.62 kB

Total Files

3

Last publish

Collaborators

  • alexblunck