🐙 GitHub Pages View Counter

Track individual repositories and pages!

This page demonstrates the GitHub Pages-specific tracking script that tracks individual repositories instead of just domains.

📊 Repository View Counter

Show views for your specific GitHub Pages repository with data-gh-page-views:

<div data-gh-page-views>Loading...</div>
Loading repository views...

🎨 Custom Format with Repository Name

Use data-format to show the repository name with {page} placeholder:

<span data-gh-page-views data-format="📈 {page}: {views} views"></span>
Loading...

🌟 Project Stats Display

Perfect for showing off your project's popularity:

<p data-gh-page-views data-format="This project has been viewed {views} times!"></p>

Loading...

🔧 How GitHub Pages Tracking Works

The GitHub Pages tracker extracts the repository name from URLs like:

📋 Available Selectors for GitHub Pages

The GitHub Pages script looks for elements with any of these selectors:

🎨 Format Options

Use the data-format attribute to customize the display:

Examples:

⚙️ Setup for GitHub Pages

  1. Add the GitHub Pages tracking script to your repository:
<script src="https://hard-house.club/track-gh-pages.js"></script>
  1. Add view counter elements anywhere on your page
  2. Deploy to GitHub Pages - each repository will be tracked separately!

💡 Use Cases

🔧 Difference from Regular Tracking

Regular tracking script: Groups all pages from username.github.io together

GitHub Pages script: Tracks username/repo-name separately for each repository

📊 API Access

Fetch your GitHub Pages view counts programmatically:

Fetch views for a specific repository:
GET https://hard-house.club/api/views-page/[username-repository]

JavaScript Example

// For repository: https://username.github.io/my-project/
fetch('https://hard-house.club/api/views-page/username-my-project')
  .then(response => response.json())
  .then(data => {
    console.log(`${data.page} has ${data.views} views`);
  });

Response Format

{
  "page": "username-my-project",
  "views": 15
}

💡 Page ID Format: GitHub URLs are converted to dash-separated format: