This page demonstrates the GitHub Pages-specific tracking script that tracks individual repositories instead of just domains.
Show views for your specific GitHub Pages repository with
data-gh-page-views:
<div data-gh-page-views>Loading...</div>
Use data-format to show the repository name with
{page} placeholder:
<span data-gh-page-views data-format="📈 {page}: {views}
views"></span>
Perfect for showing off your project's popularity:
<p data-gh-page-views data-format="This project has been viewed
{views} times!"></p>
Loading...
The GitHub Pages tracker extracts the repository name from URLs like:
https://username.github.io/repo-name/ → tracks
username/repo-name
https://george-of-croton.github.io/minimalist-ripple-client/
→ tracks george-of-croton/minimalist-ripple-client
https://username.github.io/ → tracks
username (main GitHub Pages site)
The GitHub Pages script looks for elements with any of these selectors:
[data-gh-page-views] - GitHub Pages specific[data-page-views] - Generic (backward compatible).gh-page-views - GitHub Pages CSS class.page-views - Generic CSS class#gh-page-views - GitHub Pages ID#page-views - Generic ID.view-count - CSS class#view-count - ID
Use the data-format attribute to customize the display:
{views} - The view count (automatically formatted with
commas)
{page} - The repository identifier (e.g., "username/repo")Examples:
data-format="{views}" - Just the numberdata-format="{views} views" - Number with "views" text
data-format="📊 {page} has {views} views" - With repository
name
data-format="⭐ {views} people have checked out this project!"
- Marketing style
<script
src="https://hard-house.club/track-gh-pages.js"></script>
Regular tracking script: Groups all pages from
username.github.io together
GitHub Pages script: Tracks
username/repo-name separately for each repository
Fetch your GitHub Pages view counts programmatically:
GET https://hard-house.club/api/views-page/[username-repository]
💡 Page ID Format: GitHub URLs are converted to dash-separated format:
username.github.io/repo → username-repousername.github.io → username