Simple Analytics provides API access, embeddable dashboards, and official plugins for popular platforms. This guide covers integration options for connecting Simple Analytics to your website, applications, and third-party tools.
API Access
Authentication
Simple Analytics API uses API keys for authentication.
Generate API Key:
- Log into Simple Analytics dashboard
- Navigate to Account → API Keys
- Click "Create API Key"
- Select permissions (read, write, or both)
- Copy and securely store the key
Statistics API
Retrieve Website Statistics:
curl "https://simpleanalytics.com/api/websites/example.com/stats" \
-H "Api-Key: YOUR_API_KEY"
Response:
{
"pageviews": 12543,
"visitors": 3421,
"pages": [
{
"path": "/",
"pageviews": 4532
},
{
"path": "/blog",
"pageviews": 2341
}
],
"referrers": [
{
"referrer": "google.com",
"pageviews": 2134
}
]
}
Query Parameters:
start- Start date (YYYY-MM-DD)end- End date (YYYY-MM-DD)fields- Comma-separated fields to includetimezone- Timezone for date ranges (e.g., "America/New_York")
Example with Parameters:
curl "https://simpleanalytics.com/api/websites/example.com/stats?start=2024-01-01&end=2024-01-31&fields=pageviews,visitors,pages" \
-H "Api-Key: YOUR_API_KEY"
Events API
Retrieve Custom Events:
curl "https://simpleanalytics.com/api/websites/example.com/events" \
-H "Api-Key: YOUR_API_KEY"
Send Events via API:
curl -X POST "https://queue.simpleanalyticscdn.com/events" \
-H "Content-Type: application/json" \
-H "Api-Key: YOUR_API_KEY" \
-d '{
"type": "event",
"hostname": "example.com",
"event": "signup",
"metadata": {
"plan": "pro",
"source": "homepage"
}
}'
Export Data
CSV Export:
curl "https://simpleanalytics.com/api/websites/example.com/export.csv?start=2024-01-01&end=2024-01-31" \
-H "Api-Key: YOUR_API_KEY" \
-o analytics.csv
JSON Export:
curl "https://simpleanalytics.com/api/websites/example.com/export.json?start=2024-01-01&end=2024-01-31" \
-H "Api-Key: YOUR_API_KEY" \
-o analytics.json
Rate Limits
Limits:
- 100 requests per minute per API key
- 10,000 requests per day per API key
Rate Limit Headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1640995200
Embedded Dashboards
Share analytics publicly or with password protection.
Public Dashboard
Create Public Link:
- Dashboard → Settings → Sharing
- Enable "Public dashboard"
- Copy public URL
- Share with stakeholders
Embed in Website:
<iframe
src="https://simpleanalytics.com/example.com?embed=true"
width="100%"
height="600"
frameborder="0">
</iframe>
Password-Protected Dashboard
Setup:
- Dashboard → Settings → Sharing
- Enable "Password protection"
- Set password
- Share link and password separately
Embed Options
Customization Parameters:
<iframe
src="https://simpleanalytics.com/example.com?embed=true&period=30d&timezone=America/New_York&theme=dark"
width="100%"
height="600">
</iframe>
Available Parameters:
embed=true- Remove navigation and brandingperiod=30d- Time period (7d, 30d, 90d, 12m)theme=dark- Light or dark themetimezone=- Display timezonehide_referrers=true- Hide referrer datahide_pages=true- Hide page data
Official Plugins & Integrations
WordPress
Plugin Installation:
- Install from WordPress plugin directory
- Search "Simple Analytics Official"
- Activate plugin
- Enter website hostname in settings
- Configure tracking options
Manual Integration:
Add to theme's header.php:
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
WordPress-Specific Features:
- Automatic outbound link tracking
- Scroll depth tracking
- Download tracking
- 404 error tracking
Ghost
Installation:
- Ghost Admin → Settings → Code Injection
- Add to Site Header:
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
Gatsby
Install Plugin:
npm install gatsby-plugin-simple-analytics
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-simple-analytics',
options: {
trackPageViews: true,
events: true,
eventsGlobal: 'sa_event',
ignorePages: ['/admin', '/preview']
}
}
]
}
Next.js
Install Package:
npm install simple-analytics-js
App Router (app/layout.js):
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html>
<head>
<Script
src="https://scripts.simpleanalyticscdn.com/latest.js"
strategy="afterInteractive"
/>
</head>
<body>{children}</body>
</html>
);
}
Pages Router (_app.js):
import Script from 'next/script';
export default function App({ Component, pageProps }) {
return (
<>
<Script
src="https://scripts.simpleanalyticscdn.com/latest.js"
strategy="afterInteractive"
/>
<Component {...pageProps} />
</>
);
}
Track Route Changes:
import { useRouter } from 'next/router';
import { useEffect } from 'react';
export default function App({ Component, pageProps }) {
const router = useRouter();
useEffect(() => {
const handleRouteChange = () => {
if (window.sa_event) {
window.sa_event('pageview');
}
};
router.events.on('routeChangeComplete', handleRouteChange);
return () => router.events.off('routeChangeComplete', handleRouteChange);
}, [router.events]);
return <Component {...pageProps} />;
}
Nuxt.js
Install Module:
npm install @simple-analytics/nuxt
Configure (nuxt.config.js):
export default {
modules: ['@simple-analytics/nuxt'],
simpleAnalytics: {
domain: 'example.com',
autoCollect: true,
trackEvents: true
}
}
Hugo
Add to baseof.html:
{{ if not .Site.IsServer }}
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
{{ end }}
Webflow
- Site Settings → Custom Code → Header Code
- Paste:
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
- Publish site
Shopify
- Online Store → Themes → Edit Code
- Open
theme.liquid - Add before
</head>:
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
Third-Party Integrations
Zapier
Connect Simple Analytics to Zapier:
- Create Zapier account
- Search for Simple Analytics trigger
- Authenticate with API key
- Configure trigger (e.g., "New Event")
- Connect to action in another app
Example Workflows:
- New goal completion → Send Slack notification
- Daily pageview report → Update Google Sheets
- New referrer detected → Create Airtable record
Google Sheets
Import Data via Apps Script:
function importSimpleAnalytics() {
const API_KEY = 'YOUR_API_KEY';
const DOMAIN = 'example.com';
const url = `https://simpleanalytics.com/api/websites/${DOMAIN}/stats?start=2024-01-01&end=2024-01-31`;
const options = {
headers: {
'Api-Key': API_KEY
}
};
const response = UrlFetchApp.fetch(url, options);
const data = JSON.parse(response.getContentText());
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.getRange(1, 1).setValue('Pageviews');
sheet.getRange(1, 2).setValue(data.pageviews);
}
Slack Notifications
Webhook Integration:
// Server-side code to send daily reports
const fetch = require('node-fetch');
async function sendDailyReport() {
// Fetch Simple Analytics data
const stats = await fetch('https://simpleanalytics.com/api/websites/example.com/stats', {
headers: { 'Api-Key': process.env.SA_API_KEY }
});
const data = await stats.json();
// Send to Slack
await fetch(process.env.SLACK_WEBHOOK_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: `Daily Analytics Report`,
attachments: [{
fields: [
{ title: 'Pageviews', value: data.pageviews.toString(), short: true },
{ title: 'Visitors', value: data.visitors.toString(), short: true }
]
}]
})
});
}
Custom Integrations
Server-Side Tracking
Send pageviews from your server:
Node.js:
const fetch = require('node-fetch');
async function trackPageview(path, userAgent, ip) {
await fetch('https://queue.simpleanalyticscdn.com/simple', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'User-Agent': userAgent,
'X-Forwarded-For': ip
},
body: JSON.stringify({
url: `https://example.com${path}`,
ua: userAgent
})
});
}
Python:
import requests
def track_pageview(path, user_agent, ip):
requests.post('https://queue.simpleanalyticscdn.com/simple',
headers={
'Content-Type': 'application/json',
'User-Agent': user_agent,
'X-Forwarded-For': ip
},
json={
'url': f'https://example.com{path}',
'ua': user_agent
}
)
Event Tracking
Client-Side:
// Track custom event
window.sa_event('button_click');
// Event with metadata
window.sa_event('purchase', {
amount: 99.99,
currency: 'USD',
product_id: 'PROD-123'
});
Server-Side:
async function trackEvent(eventName, metadata) {
await fetch('https://queue.simpleanalyticscdn.com/events', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'event',
hostname: 'example.com',
event: eventName,
metadata: metadata
})
});
}
Data Warehouse Integration
Export to BigQuery
Automated Daily Export:
from google.cloud import bigquery
import requests
import os
def export_to_bigquery():
# Fetch data from Simple Analytics
response = requests.get(
'https://simpleanalytics.com/api/websites/example.com/export.json',
headers={'Api-Key': os.getenv('SA_API_KEY')},
params={'start': '2024-01-01', 'end': '2024-01-31'}
)
data = response.json()
# Load to BigQuery
client = bigquery.Client()
table_id = 'project.dataset.simple_analytics'
job = client.load_table_from_json(data, table_id)
job.result()
Snowflake Integration
-- Create external function to call Simple Analytics API
CREATE OR REPLACE EXTERNAL FUNCTION fetch_analytics()
RETURNS VARIANT
API_INTEGRATION = simple_analytics_api
AS 'https://simpleanalytics.com/api/websites/example.com/stats';
-- Query analytics data
SELECT * FROM TABLE(fetch_analytics());
Best Practices
API Usage:
- Cache responses to reduce API calls
- Use appropriate date ranges to minimize data transfer
- Store API keys securely (environment variables, secrets manager)
- Implement error handling and retry logic
- Monitor rate limit headers
Embedded Dashboards:
- Use password protection for sensitive data
- Customize embed parameters for your audience
- Consider mobile responsiveness when embedding
- Test iframe loading performance
- Provide context around embedded analytics
- Use consistent naming conventions
- Avoid tracking sensitive user data
- Limit metadata to necessary information
- Test events in development before production
- Document custom events for team reference