• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ncb000gt/node-googleanalytics: Google Analytics data exporting library for NodeJ ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

ncb000gt/node-googleanalytics

开源软件地址(OpenSource Url):

https://github.com/ncb000gt/node-googleanalytics

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

Google Analytics

UNMAINTAINED: In case it wasn't clear from the lack of activity, I don't have the time to work on this project anymore.
I'd be happy to transfer ownership to someone else or add someone as a contributor to the project. Please reach out to me
and let me know!


This project doesn't work and hasn't worked for some time due to google removing the use based configuration.
	See more at https://github.com/ncb000gt/node-googleanalytics/issues/36#issuecomment-383822453

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.

  • Updated for NodeJS 0.6.x *

Usage

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 access token you have:

var GA = require('googleanalytics'),
    util = require('util'),
    config = {
        "token": "XXXXXXXXXXXX"
    },
    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));
});

You can specify the type of token by setting 'tokenType', default is 'Bearer'.

See node-gapitoken for easy service account Server to Server authorization flow.

API

  • login([callback]) - The callback is optional. However, if it is given, it is added to the token event.
  • get(options, callback)

Event API

  • token(err, token)
  • entries(err, entries)

Entry API

  • metrics[]
  • dimensions[]

Each array contains objects. These objects contain the following:

  • name - The name of the metric or dimension requested
  • value - The value associated. If the value is a Number, it is parsed for you. Otherwise, it will be a string.

Contributors

License

see license file




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Bioconductor/GoogleGenomics: An R package for Google Genomics API queries.发布时间:2022-06-12
下一篇:
sahibjotsaggu/Google-Sans-Fonts发布时间:2022-06-12
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap