Socket
Book a DemoInstallSign in
Socket

google-analytics-lite

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-analytics-lite

A lightweight google Analytics module.

0.0.1
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

google-analytics-lite npm GitHub JavaScript Style Guide

A lightweight google Analytics module.

Features

  • Lightweight
  • TypeScript support

Why?

Most other modules (such as universal-analytics and electron-google-analytics) are too large (more than 1MB) after packaging due to the import of module request, these modules also do not support TypeScript.

Install

npm install google-analytics-lite

Usage

Init

new GoogleAnalytics(tid: string, cid?: string, fetcher?: typeof fetch, root?: string)

import GoogleAnalytics from 'google-analytics-lite'

const ga = new GoogleAnalytics('UA-123456-1')

Default values

By editing gs.defaultValues:

Object.assign(gs.defaultValues, {
  an: 'My App',
  aid: 'com.company.app'
})

Protocol

pageView(dl: string, dh?: string, dp?: string, other?: GAParameters)

ga.pageView('http://examples.com/a.html').then(console.log)

event(ec: string, ea: string, el?: string, ev?: number, other?: GAParameters)

ga.event('audio', 'Play')

exception(exd?: string, exf?: boolean, other?: GAParameters)

ga.exception('Audio play exception')

social(sn: string, sa: string, st: string, other?: GAParameters)

ga.social('facebook', 'like', 'http://example.com/myApp')

Other

ga.post({ cn: 'xxx', cs: 'xxx' }) // ga.post(data: GAParameters)

If you need other protocols, please contact me through github issue! :)

Utils

import { assign, genUUID, random } from 'google-analytics-lite'

random(4) // Random string
genUUID() // Random UUID
assign(obj1, obj2) // Assign two objects

Author

Shirasawa

License

MIT

Keywords

google

FAQs

Package last updated on 14 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.