Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated readme

  • Loading branch information...
commit fd1c2021aef2cc38b1bd9cc1e7dfaa5f40753ad7 1 parent cb5b02d
@rowanu rowanu authored
Showing with 48 additions and 18 deletions.
  1. +48 −18 README.md
View
66 README.md
@@ -3,7 +3,8 @@ Google Analytics
Pull data from Google Analytics for use in projects.
-The library maintains tracking of the token so that you don't have to and will push the token around with your requests. Should you require a different token, just create a new GA instance. However, this is asynchronous through eventing so if you do want the token you can latch onto the event.
+The library maintains tracking of the token so that you don't have to and will push the token around with your requests.
+Should you require a different token, just create a new GA instance. However, this is asynchronous through eventing so if you do want the token you can latch onto the event.
* Updated for NodeJS 0.6.x *
@@ -11,23 +12,52 @@ The library maintains tracking of the token so that you don't have to and will p
Usage
============
- var ga = require('googleanalytics')
- ,util = require('util');
-
- var GA = new ga.GA();
- GA.login(function(err, token) {
- var options = {
- 'ids': 'ga:<profileid>',
- 'start-date': '2010-09-01',
- 'end-date': '2010-09-30',
- 'dimensions': 'ga:pagePath',
- 'metrics': 'ga:pageviews',
- 'sort': '-ga:pagePath'
- };
- GA.get(options, function(err, entries) {
- util.debug(JSON.stringify(entries));
- });
- });
+With a user and password:
+
+ var GA = require('googleanalytics'),
+ util = require('util'),
+ config = {
+ "user": "myusername",
+ "password": "mypassword"
+ },
+ ga = new GA.GA(config);
+
+ ga.login(function(err, token) {
+ var options = {
+ 'ids': 'ga:<profileid>',
+ 'start-date': '2010-09-01',
+ 'end-date': '2010-09-30',
+ 'dimensions': 'ga:pagePath',
+ 'metrics': 'ga:pageviews',
+ 'sort': '-ga:pagePath'
+ };
+
+ GA.get(options, function(err, entries) {
+ util.debug(JSON.stringify(entries));
+ });
+ });
+
+If you have already gotten permission from a user, you can simply use the oAuth refresh token you have:
+
+ var GA = require('googleanalytics'),
+ util = require('util'),
+ config = {
+ "token": "Auth=XXXXXXXXXXX"
+ },
+ ga = new GA.GA(config);
+
+ var options = {
+ 'ids': 'ga:<profileid>',
+ 'start-date': '2010-09-01',
+ 'end-date': '2010-09-30',
+ 'dimensions': 'ga:pagePath',
+ 'metrics': 'ga:pageviews',
+ 'sort': '-ga:pagePath'
+ };
+
+ GA.get(options, function(err, entries) {
+ util.debug(JSON.stringify(entries));
+ });
Rudamentary API
Please sign in to comment.
Something went wrong with that request. Please try again.