Google Analytics API

Make a simple endpoints of your website daily. monthly pageviews and users data to make simple and nice interface about your website analytics.


Base Endpoint

For Google Analytics API, the format of your endpoint ⤵️<username>/ga/<token>

- username- your nocodeapi username.

- token- every api have unique token. See your API card when you setup API.

API Error Codes:

If your query fails, API will return a 3-digit error-code and info as plain text

Error response example: If you provide a invalid key or do not send one, you will be responded with Unauthorised Access in below format.

    "error": 1,
    "code": 401,
    "info": "Unauthorized"

Common API Errors:

Code Info [affected API endpoints]
200 (OK)Standard response for successful GET, POST, UPDATE & DELETE
400 (Bad Request)Error response when creating (POST) or updating (UPDATE, DELETE).
401 (Unauthorized)Error response when wrong or invalid API key
402 (Payment Required)Returned if pro feature is tried to be accessed from free account
403 (Forbidden)Error response when action is forbidden by the user (API owner)
404 (No such route) Route is not valid or query params is in-valid.
429 (Rate limit exceeded)Your API request limit exceeded per month.
500 (Server error)Server error

API Endpoints

Analytics Data

Make the GET request on below endpoint to get Analytics Data for diffrent metrics.<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo

- Request Parameters:

metrics[Required] pageviews or users
startDate[Required] Start date of your data range 1daysAgo, 7daysAgo, 14daysAgo, 28daysAgo, 30daysAgo, or Ex: YYYY-MM-DD.
endDate[Optional] End date of your data range. by default is 'today'
dimensions[Optional] date, browser, country, fullReferrer, pagePath, or deviceCategory, default value is date
orderBys[Optional] descending or ascending. default value no sorting

- Code Examples

const axios = require('axios');
    method: 'get',
    url: '<username>/ga/<token>', 
    params: {metrics: 'pageviews',startDate: '7daysAgo'},
}).then(function (response) {
        // handle success
}).catch(function (error) {
        // handle error

More Endpoints Examples

- Pageviews<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo

- Users<username>/ga/<token>?metrics=users&startDate=7daysAgo&dimensions=date

- Browsers<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=browser

- Devices<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=deviceCategory

- Country<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=country

- Source<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=source

- Top Pages<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=pagePath