Socket
Socket
Sign inDemoInstall

google-analyticsreporting

Package Overview
Dependencies
63
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    google-analyticsreporting

server-side reporting module for google analytics reporting api v4


Version published
Weekly downloads
266
decreased by-17.39%
Maintainers
1
Install size
15.0 MB
Created
Weekly downloads
 

Readme

Source

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);
    })
  );

Keywords

FAQs

Last updated on 14 Mar 2018

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc