# gadispatcher

> Simplified API for dispatching requests to Google Analytics

Latest version **1.0.0** (published 2016-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install gadispatcher
pnpm add gadispatcher
yarn add gadispatcher
bun add gadispatcher
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-12-12 |
| First published | 2016-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | @doot0 |
| Maintainers | doot0 |
| Keywords | ga, google, analytics |

## Links

- npm: https://www.npmjs.com/package/gadispatcher
- npm.io page: https://npm.io/package/gadispatcher

## Dependencies (1)

- [universal-analytics](https://npm.io/package/universal-analytics.md) ^0.4.8

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-12-12

## README

## gadispatcher [![npm](https://img.shields.io/npm/v/gadispatcher.svg)]()

GADispatcher is a highly simplified API for sending any type of event to
Google Analytics. (WIP: Any requests made with this library that fail are
gracefully queued in the background to resend later.)

:warning: There are currently no tests for this library. :warning:

### Usage

##### API
###### GADispatcher(trackingId, [identifier], [options])
Calling `new GADispatcher()` instantiates the GADispatcher instance.

- `trackingId` - A Google Analytics tracking ID.
- `[identifier]` - An optional V4 UUID. One is generated and stored between sessions if no UUID is passed.
- `[options]` - See the [`universal-analytics` documentation](https://github.com/peaksandpies/universal-analytics/blob/master/README.md#getting-started) for available options.

###### send(eventType, [metadata])
- `eventType` - Kind of event to send. Currently available events are `pageview`, `event`, `transaction`, `exception` and `timing`.
- `[metadata]` - Optional metadata as an object. [`universal-analytics` documentation](https://github.com/peaksandpies/universal-analytics/blob/master/AcceptableParams.md) for available options.

##### Example
If you prefer examples, I got you.

###### Instantiating an instance:
```js
// Set up some vars
const GA_ID = 'UA-123456-78'
const UUID = '123e4567-e89b-12d3-a456-426655440000'

const GA_OPTS = {
  https: true // on by default
}

// Ready
const ga = new GADispatcher(GA_ID, UUID)
```

###### Sending a request:
```js
// Configure some data about an event
const recordingEvent = {
  eventCategory: 'User action',
  eventAction: 'Started recording'
}

// Sends an event type request to Google Analytics
ga.send('event', recordingEvent)
```

---
_Source: https://npm.io/package/gadispatcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
