0.3.0 • Published 6 years ago

@blunck/ga v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@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' })