diff --git a/GOATCOUNTER_SETUP.md b/GOATCOUNTER_SETUP.md new file mode 100644 index 00000000..13e9075a --- /dev/null +++ b/GOATCOUNTER_SETUP.md @@ -0,0 +1,91 @@ +# GoatCounter Analytics Integration + +This MkDocs site is now integrated with GoatCounter for privacy-friendly analytics tracking. + +## What's Been Set Up + +### 1. Tracking Script +- The GoatCounter tracking script is automatically loaded on all pages +- Your tracking code: `https://learningresource.goatcounter.com/count` + +### 2. Analytics Display +- **Homepage**: Shows a total site view counter and link to public dashboard +- **All Pages**: Each page displays an analytics widget at the bottom with: + - Link to view detailed dashboard + - Expandable section showing page-specific view counter (when available) + +### 3. Configuration +The GoatCounter integration is configured in `mkdocs.yml`: + +```yaml +extra: + goatcounter: + site: learningresource + domain: learningresource.goatcounter.com +``` + +## How to Use + +### View Analytics Dashboard +1. Go to [https://learningresource.goatcounter.com/](https://learningresource.goatcounter.com/) +2. View real-time statistics including: + - Page views per page + - Total site views + - Visitor locations (anonymized) + - Browser and device statistics + - Referrer information + +### Enable Public Statistics Display (Optional) +If you want to show individual page view counters publicly: + +1. Go to your GoatCounter settings +2. Enable "Public statistics" +3. The page-specific counters will automatically start working + +### Customize Analytics Display +- Edit `docs/overrides/main.html` to modify the analytics widget +- Edit `docs/overrides/stylesheets/goatcounter.css` to change styling +- Modify `docs/index.md` to adjust the homepage analytics section + +## Files Created/Modified + +``` +mkdocs.yml # Added GoatCounter config +docs/overrides/main.html # Custom template with analytics +docs/overrides/stylesheets/goatcounter.css # Analytics styling +docs/index.md # Added analytics section +``` + +## Privacy Features + +GoatCounter is designed with privacy in mind: +- ✅ No cookies +- ✅ No tracking across sites +- ✅ No personal data collection +- ✅ Respects Do Not Track +- ✅ GDPR compliant +- ✅ Open source + +## Testing + +To test the integration: +1. Build and serve your site: `mkdocs serve` +2. Visit different pages +3. Check the GoatCounter dashboard to see if visits are being tracked +4. Verify the analytics widgets appear on each page + +## Troubleshooting + +**Visits not being tracked?** +- Check that the GoatCounter script loads without errors in browser dev tools +- Verify your GoatCounter site URL is correct +- Ensure JavaScript is enabled + +**Analytics widgets not appearing?** +- Check that the custom theme directory is being used +- Verify the `custom_dir: overrides` setting in mkdocs.yml +- Make sure the CSS file path is correct + +**Public counters not working?** +- Enable public statistics in your GoatCounter settings +- Wait a few minutes for the setting to take effect \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 7e58c824..185118d1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,4 +17,19 @@ This is a comprehensive resource for learning various aspects of computer scienc - Data Structures and Algorithms - Machine Learning - OS Development -- Reverse Engineering \ No newline at end of file +- Reverse Engineering + +## 📈 Site Analytics + +We use [GoatCounter](https://www.goatcounter.com/) for privacy-friendly analytics. View our [public statistics dashboard](https://learningresource.goatcounter.com/) to see: + +- 📊 Total page views across the site +- 📈 Popular pages and sections +- 🌍 Visitor locations (anonymized) +- 📱 Device and browser statistics + + + +*Statistics are updated in real-time and respect visitor privacy.* \ No newline at end of file diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 00000000..946d1147 --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} + +{% block analytics %} + {{ super() }} + {% if config.extra.goatcounter %} + + {% endif %} +{% endblock %} + +{% block content %} + {{ super() }} + + + {% if config.extra.goatcounter %} +
+
+
+

📊 Analytics

+ + View Dashboard → + +
+ +

+ 📈 This page is being tracked with GoatCounter. + + Click here to view detailed analytics + including page views, referrers, and visitor statistics. +

+ + +
+
+ Show Public Statistics +
+ + + Live view counter for this page + +
+
+
+
+
+ {% endif %} +{% endblock %} \ No newline at end of file diff --git a/docs/overrides/stylesheets/goatcounter.css b/docs/overrides/stylesheets/goatcounter.css new file mode 100644 index 00000000..b84264fd --- /dev/null +++ b/docs/overrides/stylesheets/goatcounter.css @@ -0,0 +1,79 @@ +/* GoatCounter Analytics Styles */ + +.goatcounter-stats { + transition: all 0.3s ease; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.goatcounter-stats:hover { + transform: translateY(-2px); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); +} + +.goatcounter-widget { + transition: all 0.3s ease; +} + +.goatcounter-widget:hover { + transform: translateY(-1px); + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); +} + +/* Dark mode adjustments */ +[data-md-color-scheme="slate"] .goatcounter-stats { + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); +} + +[data-md-color-scheme="slate"] .goatcounter-stats:hover { + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); +} + +/* Analytics iframe styling */ +.goatcounter-stats iframe { + border-radius: 0.2rem; + background: var(--md-default-bg-color); +} + +/* Summary/Details styling for collapsible stats */ +.goatcounter-stats details > summary { + list-style: none; + padding: 0.5rem 0; + border-bottom: 1px solid var(--md-default-fg-color--lightest); +} + +.goatcounter-stats details > summary::-webkit-details-marker { + display: none; +} + +.goatcounter-stats details > summary::before { + content: "▶"; + margin-right: 0.5rem; + transition: transform 0.2s ease; + color: var(--md-primary-fg-color); +} + +.goatcounter-stats details[open] > summary::before { + transform: rotate(90deg); +} + +/* Responsive design for mobile */ +@media (max-width: 768px) { + .goatcounter-stats { + padding: 1rem; + margin: 1rem 0; + } + + .goatcounter-stats h3 { + font-size: 1.1rem; + } +} + +/* Animation for view counter */ +@keyframes countUp { + from { opacity: 0; transform: translateY(10px); } + to { opacity: 1; transform: translateY(0); } +} + +.view-count { + animation: countUp 0.5s ease; +} \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 8878f5ef..dfeaed6a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,7 @@ site_name: Am I Learning Enough theme: name: material + custom_dir: docs/overrides features: - navigation.tabs - navigation.sections @@ -87,3 +88,14 @@ nav: - Without C: roadmap/os-dev/noC.md - Reverse Engineering: - RE: roadmap/reverse-engineering/reverse-engineering.md + +extra_javascript: + - https://gc.zgo.at/count.js + +extra_css: + - stylesheets/goatcounter.css + +extra: + goatcounter: + site: learningresource + domain: learningresource.goatcounter.com