Last 30 days
/stats/summaryEndpoints
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.
Totals
Visitors, page views, visits, bounce rate, visit duration, and link clicks, next to the period before.
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.
Top lists
Top pages, sources, referrers, campaigns, countries, cities, devices, browsers, goals, and links.
Right now
Visitors in the last five minutes.
Every user's page
For platforms. Every profile or store, ranked by visitors. Analytics for Platforms
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
Add the script.
Paste one line into the
<head>of your site. Visits show up within seconds.Create a key.
Create a secret key in your app's settings. Keep it on your server.
Ask for the numbers.
Send the key in the Authorization header. The answer is JSON with the same numbers as your dashboard.
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