ga-report

Unofficial NodeJS wrapper for the Google Analytics Core Reporting API

Usage no npm install needed!

<script type="module">
  import gaReport from 'https://cdn.skypack.dev/ga-report';
</script>

README

Google Analtyics Reporting Build Status

NodeJS wrapper for Google Analytics Core Reporting API

API

Instanciate

Report = require('ga-report');

var report = new Report('user@gmail.com', 'mypassword');
var report.once('ready', function() {
  // ready to report
});

Get Accounts

report.getAccounts(function(err, accounts) {
  console.error(err);
  for (var i = 0; i < accounts.length; i++) {
    console.log(accounts[i]);
  }
});

Get Webproperties

report.getWebproperties(accountId, function(err, webproperties) {
  console.error(err);
  for (var i = 0; i < webproperties.length; i++) {
    console.oog(webproperties[i]);
  }
});

Get Webproperties

report.getWebproperties(accountId, webpropertyId, function(err, profile) {
  console.error(err);
  for (var i = 0; i < profiles.length; i++) {
    console.oog(profiles[i]);
  }
});

Get Report

var options = {
  'ids': 'ga:123456-UA',
  'start-date': '2013-10-01',
  'end-date': '2013-10-31',
  'metrics': 'ga:visits,ga:bounces'
};
report.get(options, functon(err, data) {
  if (err) console.error(err);
  console.dir(data);
)};