Skip to content
/ ga Public

Simple tool to add Google Analytics tracking code to your website

Notifications You must be signed in to change notification settings

alexblunck/ga

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple tool to add Google Analytics tracking code to your website

Resources

Stars

Watchers

Forks

Packages

No packages published