goat counter update
Some checks failed
Deploy MkDocs / deploy (push) Has been cancelled

This commit is contained in:
Mohit Mishra
2025-07-20 23:00:17 +05:30
parent 979484a3fc
commit 109d5f454e
5 changed files with 249 additions and 1 deletions

91
GOATCOUNTER_SETUP.md Normal file
View File

@@ -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

View File

@@ -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
- 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
<iframe src="https://learningresource.goatcounter.com/counter/total.svg"
style="border: none; width: 100%; height: 60px; margin: 1rem 0;"
title="Total Site Views"></iframe>
*Statistics are updated in real-time and respect visitor privacy.*

51
docs/overrides/main.html Normal file
View File

@@ -0,0 +1,51 @@
{% extends "base.html" %}
{% block analytics %}
{{ super() }}
{% if config.extra.goatcounter %}
<script data-goatcounter="https://{{ config.extra.goatcounter.domain }}/count"
async src="//gc.zgo.at/count.js"></script>
{% endif %}
{% endblock %}
{% block content %}
{{ super() }}
<!-- GoatCounter Analytics Widget -->
{% if config.extra.goatcounter %}
<div class="md-content__inner md-typeset" style="margin-top: 2rem;">
<div class="goatcounter-stats" style="padding: 1.5rem; background: var(--md-code-bg-color); border-radius: 0.3rem; border-left: 4px solid var(--md-primary-fg-color);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;">
<h3 style="margin: 0; color: var(--md-default-fg-color);">📊 Analytics</h3>
<a href="https://{{ config.extra.goatcounter.domain }}"
target="_blank"
style="color: var(--md-primary-fg-color); text-decoration: none; font-weight: 500;">
View Dashboard →
</a>
</div>
<p style="margin: 0; color: var(--md-default-fg-color--light); font-size: 0.9rem;">
📈 This page is being tracked with GoatCounter.
<a href="https://{{ config.extra.goatcounter.domain }}" target="_blank" style="color: var(--md-primary-fg-color);">
Click here to view detailed analytics
</a> including page views, referrers, and visitor statistics.
</p>
<!-- Optional: Embed public stats if available -->
<div style="margin-top: 1rem;">
<details style="cursor: pointer;">
<summary style="color: var(--md-primary-fg-color); font-weight: 500;">Show Public Statistics</summary>
<div style="margin-top: 1rem; padding: 1rem; background: var(--md-default-bg-color); border-radius: 0.2rem;">
<iframe src="https://{{ config.extra.goatcounter.domain }}/counter/{{ page.url | default('') }}.svg"
style="border: none; width: 100%; height: 40px;"
title="GoatCounter Statistics"></iframe>
<small style="display: block; margin-top: 0.5rem; color: var(--md-default-fg-color--light);">
Live view counter for this page
</small>
</div>
</details>
</div>
</div>
</div>
{% endif %}
{% endblock %}

View File

@@ -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;
}

View File

@@ -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