DataDad.

Web analytics API

Read your website stats from your own code.

Send one request with your key. You get visitors, page views, top pages, sources, and link clicks as JSON, with visits from a few seconds ago. Put them in your admin panel or a weekly email.

  • One secret key
  • No OAuth
  • Visits in seconds

Endpoints

What the API returns

There are five endpoints. Each one takes a period: a preset from the last hour to the last 3 years, or two dates.

/stats/summary

Totals

Visitors, page views, visits, bounce rate, visit duration, and link clicks, next to the period before.

/stats/timeseries

A chart

Points per hour, day, week, or month. Hours or days with no visits come back as zero, so the chart has no gaps.

/stats/breakdown

Top lists

Top pages, sources, referrers, campaigns, countries, cities, devices, browsers, goals, and links.

/stats/realtime

Right now

Visitors in the last five minutes.

tenant = …

One user at a time

Add a tenant ID to any request to get the numbers of one user's page.

How it works

Set up the API

  1. Add the script.

    Paste one line into the <head> of your site. Visits show up within seconds.

  2. Create a key.

    Create a secret key in your app's settings. Keep it on your server.

  3. Ask for the numbers.

    Send the key in the Authorization header. The answer is JSON with the same numbers as your dashboard.

Read the API documentation

Details

Keys, limits, and data

One key, no OAuth

Create a key in settings and send it as a bearer token. Revoke the key and its access stops.

Visits show up in seconds

The API has each visit seconds after it happens. We cache each answer for one minute.

Same numbers as the dashboard

The API counts visitors, visits, and bounces the same way your DataDad dashboard does.

60 requests a minute

Per app, for all its keys together. Answers from the cache do not count. Over the limit, you get a 429 with a Retry-After header.

Clicks on outbound links

We count clicks on links to other sites, and the API gives them per link.

Cookieless by default

The script is less than 2 KB compressed and sets no cookies to track visitors.

FAQ

Questions about the web analytics API

What is a web analytics API?

It is a way for your own code to read website statistics, such as visitors, page views, and sources, instead of reading them on a dashboard. You can show them in your app, send them to a report, or check them in a script.

How do I authenticate?

Create a secret key in your app's settings and send it in the Authorization header as a bearer token. Each key reads one app. Keep keys on your server.

How fresh is the data?

A visit is available seconds after it happens. Answers are kept for one minute, so the same request within a minute returns the same numbers.

Can I call the API from a browser?

No. The API sends no CORS headers, so a secret key cannot be used from a web page. Call it from your server and pass the result to your page.

Which periods can I ask for?

The last hour, 24 hours, 7, 30, or 90 days, the last year or 3 years, today, yesterday, the week, month, or year to date, or any two dates up to 3 years apart.

Can I get statistics for each user of my platform?

Yes. Add a tenant ID to the script on each user's page, then add the same ID to your API requests. Analytics for Platforms.

Also in DataDad

Other DataDad products

Add your website

Enter your email to get started.