# google-analyticsreporting

> server-side reporting module for google analytics reporting api v4

Latest version **1.0.8** (published 2018-03-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install google-analyticsreporting
pnpm add google-analyticsreporting
yarn add google-analyticsreporting
bun add google-analyticsreporting
```

## 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.8 |
| Published | 2018-03-14 |
| First published | 2018-03-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jesse R. Castro |
| Maintainers | jesse.r.castro |
| Keywords | google, analytics, ga, analyticsreporting |

## Links

- npm: https://www.npmjs.com/package/google-analyticsreporting
- Repository: https://github.com/JesseCastro/google-analyticsreporting
- Homepage: https://github.com/JesseCastro/google-analyticsreporting#readme
- Issues: https://github.com/JesseCastro/google-analyticsreporting/issues
- npm.io page: https://npm.io/package/google-analyticsreporting

## Dependencies (2)

- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1
- [googleapis](https://npm.io/package/googleapis.md) ^27.0.0

## 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.8 (latest) — 2018-03-14
- 1.0.7 — 2018-03-13
- 1.0.6 — 2018-03-13
- 1.0.5 — 2018-03-13
- 1.0.4 — 2018-03-13
- 1.0.3 — 2018-03-12
- 1.0.2 — 2018-03-12
- 1.0.0 — 2018-03-12

## README

# Google Analytics Reporting API node module

Node module to access analytics reporting v4 api.  

## Prerequisites

You'll need to set up a google project with a service user and download the service user JSON file.  

## Installing

To add this to your node project type the following at the command line:
```
npm install --save google-analyticsreporting
```

## Using the package

You'll need to include the JSON from the Prerequisites section like so:

```
var key = require('./path/to/secret.json');
```
First you'll need to run the auth command, then you can `then` into the `query` function.

```
const ga = require('google-analyticsreporting');
var key = require('./secret/secret.json');


const reportRequests = {
  reportRequests:
    [
      {
        viewId: '<YOUR VIEW ID HERE>',
        dateRanges:
          [
            {
              endDate: '2018-01-18',
              startDate: '2018-01-18',
            },
          ],
          metrics:
          [
            {
              expression: 'ga:dcmCost',
            },
            {
              expression: 'ga:dcmClicks',
            },
            {
              expression: 'ga:dcmImpressions',
            },
          ],
          dimensions:
          [
            {
              name: 'ga:dcmLastEventCampaign',
            },
          ],
      },
  ],
};

ga.auth(key)
  .then(
    ga.query(reportRequests)
    .then(function(error,results){
      var csv = ga.makecsv(error,results);
      console.log(csv);
    })
  );
```

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