Analytics Integration
Learn how to add privacy-respecting analytics to your website.
Script Installation
If you have already installed the script, skip this section. All features are provided via a single unified privatestater.js script.
Add the following script to the <head> section of your website:
<script> window.PrivateStaterConfig = { prstSite: "YOUR_SITE_ID" }; </script>
<script src="https://privatestater.com/privatestater.js"></script>
Replace YOUR_SITE_ID with the Website ID created in the dashboard.
Once the script is installed, the analytics feature is automatically enabled.
Automatically Collected Data
When the script is installed, the following data is automatically collected:
| Data | Description | Example |
|---|---|---|
| Visitors | Unique visitors per hour | Aggregated hourly |
| Page Path | Visited URL path | /, /about, /blog/post-1 |
| Browser | Browser type used | Chrome, Firefox, Safari |
| Device Type | Device classification | Desktop, Mobile, Tablet |
| Language | Browser language setting | ko, en, ja |
| Referrer | Traffic source | google.com, twitter.com |
Privacy Protection Methods
- IP Hashing: IP addresses are hashed combined with date+time. Original IPs are not stored.
- Hourly Deduplication: Multiple visits by the same visitor in the same hour are counted as 1 visit.
- No Cookies: I do not use cookies to track visitors.
Traffic Source Tracking
You can track visitor traffic sources using URL parameters.
Supported Parameters
Adding one of the following parameters to the URL will automatically record it as a referrer:
| Parameter | Usage | Example URL |
|---|---|---|
src |
General Source | example.com?src=newsletter |
source |
General Source | example.com?source=twitter |
ref |
Referral | example.com?ref=partner |
utm_source |
UTM Campaign | example.com?utm_source=google |
Usage Examples
When linking from a newsletter:
https://example.com/landing?src=newsletter
When sharing on social media:
https://example.com/blog/post?source=mastodon
From a partner website:
https://example.com?ref=partner-website
If a source parameter is present, it takes precedence over the HTTP Referer header.
Click Tracking
Use the JavaScript API to track clicks on specific buttons or links.
Basic Usage
window.PrivateStater.statsClick("button_id");
Real World Example
<button onclick="window.PrivateStater.statsClick('signup_button')">
Sign Up
</button>
<a href="/pricing" onclick="window.PrivateStater.statsClick('pricing_link')">
View Pricing
</a>
Event Listener Method
document.getElementById('cta-button').addEventListener('click', function() {
window.PrivateStater.statsClick('cta_main');
});
Button ID Rules
- Alphanumeric characters, hyphens (
-), underscores (_) allowed - No spaces allowed
- Maximum 100 characters
Viewing Statistics in Dashboard
Query Period
You can view statistics for the following periods in the dashboard:
| Period | Description |
|---|---|
| 1 Hour | Last 1-2 hours |
| 12 Hours | Last 12 hours |
| 1 Day | Last 24 hours |
| 3 Days | Last 3 days |
| 7 Days | Last 1 week |
| 14 Days | Last 2 weeks |
| 30 Days | Last 1 month |
| 6 Months | Last 6 months |
| 1 Year | Last 1 year |
Statistic Types
| Statistic | Description |
|---|---|
| Visitors | Visitor ratio and count by time |
| Browser | Visitor ratio and count by browser |
| Device | Ratio and count for Desktop/Mobile/Tablet |
| Language | Visitor language ratio and count |
| Page | Ratio and count of entered pages |
| Referrer | Ratio and count of traffic sources |
| Clicks | Click ratio and count |
Bot Detection
PrivateStater automatically detects known bots and classifies them separately:
- Search Engine Crawlers (Googlebot, Bingbot, etc.)
- Monitoring Tools (Pingdom, UptimeRobot, etc.)
- SNS Preview Bots (Mastodon, Twitter, etc.)
Bot traffic is distinguished from regular visitor statistics and displayed as the bot name in the device type.
Troubleshooting
Statistics are not showing up
- Check if the script is installed correctly.
- Check if
YOUR_SITE_IDmatches the Website ID in the dashboard. - Check for errors in the browser developer tools console.
- Check if an ad blocker is blocking the script.
Testing on localhost doesn't work
Statistics are not recorded for local development environments or unsecured connections. Actual statistics are only recorded in production environments.