Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GA Test Site

A minimal static two-page website for testing Google Analytics 4, deployed to GitHub Pages via GitHub Actions.

Files

File Purpose
index.html Home page (route 1)
about.html About page (route 2)
styles.css Shared styling
app.js "Start a new session" button behavior
.github/workflows/deploy.yml GitHub Actions → GitHub Pages deploy
.nojekyll Tells Pages to skip Jekyll processing

Setup (do this before / after pushing)

1. Add your Google Analytics Measurement ID

  1. In Google Analytics create a GA4 property and a Web data stream for your Pages URL (https://<username>.github.io/<repo>/).
  2. Copy the Measurement ID (looks like G-XXXXXXXXXX).
  3. Replace G-XXXXXXXXXX in both index.html and about.html. It appears twice per file (in the script src URL and the GA_MEASUREMENT_ID variable) — 4 replacements total.

2. Push to GitHub

git init
git add .
git commit -m "Initial GA test site"
git branch -M main
git remote add origin https://github.com/<username>/<repo>.git
git push -u origin main

The repo must be public for free GitHub Pages (or you need a paid plan).

3. Enable GitHub Pages

In the repo: Settings → Pages → Build and deployment → Source: GitHub Actions. The workflow runs on every push to main (and can be triggered manually from the Actions tab). Once it succeeds, your site is live at the URL shown in the workflow's deploy step.

How session / visit testing works

  • New tab = new session. GA4 normally shares one session across tabs. Each page uses per-tab sessionStorage to detect a fresh tab and mint a unique session_id, so opening the site in a new tab counts as a new session / unique visit. Closing the tab clears the flag.
  • Same-tab reset. Click "Start a new session" on either page to clear the flag and reload, forcing a fresh session without opening a new tab.
  • Two routes. index.html and about.html are tracked as separate page views — check Reports → Engagement → Pages and screens in GA4.

Watching hits live

Open browser dev tools → Network tab → filter for collect. You'll see a request fire to Google on each page view and session start. GA4's Realtime report also shows activity within a few seconds.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages