1.0.3 • Published 2 years ago

ga-realtime-js v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

ga-realtime-js

Get Realtime report from Google Analytics

Install

npm install ga-realtime-js

Usage

const GA = require('ga-realtime-js')
const GAOptions = {
    GAID: 'ga:000000000',
    serviceAccountKey: {
        "type": "service_account",
        "project_id": "xxxxx-xxxxx-xxxx",
        "private_key_id": "xxxxxxxxxxxxxxxxxxxxxxx",
        "private_key": "-----BEGIN PRIVATE KEY-----\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n-----END PRIVATE KEY-----\n",
        "client_email": "xxxxxxxxx@[GOOGLE_PROJECT_ID].iam.gserviceaccount.com",
        "client_id": "xxxxxxxxxxxxxxxx",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://accounts.google.com/o/oauth2/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    },
    metrics: 'rt:activeUsers',
    dimensions: 'rt:pagePath',
    fields: 'rows',
    filters: `rt:pagePath=~(/testes/([0-9]+)-([^/]*))`,
    limit: 10,
    sort: '-rt:activeUsers'
}

const ga = new GA(GAOptions)
ga.get().then(res => {
    console.log(res?.data)
}).catch(e => {
    console.log(e)
})

License

MIT © Piero Ribeiro

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago