Read a web page like a tracking pro
Just enough HTML, CSS, JavaScript and browser DevTools to read a page for tracking. You won't build pages here, you'll learn to read them. Every section has something you can click or type.
- 0 · Page load 8m
- 1 · HTML 15m
- 2 · CSS 10m
- 3 · JS 20m
- 4 · DevTools 32m
- 5 · Wrap-up 5m
0 How a page loads
- The browser requests a URL and gets back an HTML document.
- It then fetches CSS, JS, images and third-party scripts the HTML points to.
- A tag is just a script the page loads. GTM is a script that loads with the page and then loads other scripts.
- Load order matters: a tag can fire before the data it needs exists.
Demo: watch a page load
- Browser requests the URL
- Server returns HTML
- CSS and images fetched
- GTM script loads, then loads other scripts
- A tag fires, e.g. a GA4 pageview
- Page data (user ID, product) finishes loading too late
This frames everything after it. The Network tab demo later is this timeline made visible.
1 HTML: the structure of a page
HTML is the document the browser receives and reads top to bottom. It's made of tags: opening and closing (<p>…</p>) or self-closing (<img>, <input>).
The page skeleton
Tap a part to see what it does.
<!DOCTYPE html> <html> <head> <title>My page</title> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> <script src="analytics.js"></script> </head> <body> <h1>Hello</h1> <p>Everything visible lives here.</p> </body> </html>
Pick a part above.
Common elements
Headings, <p> | Titles and paragraphs of text |
<a> / <img> | A link (href) / an image (src, alt) |
<div> / <span> | Generic containers: block-level / inline |
<button> | Something to click |
<form>, <input>, <select> | A form and its fields |
<iframe> | A separate page embedded inside this one |
Attributes
name="value" pairs on a tag:
id: unique on the page.class: reusable, several per element.href,src,alt,type,name: standard attributes.data-*: custom attributes, e.g.data-track="cta".
Demo: inspect any element
Click anything in the box. You'll see its tag, attributes, parent, children and siblings.
| Tag | - |
| Attributes | - |
| Parent | - |
| Children | - |
| Siblings | - |
Notice that clicking the star hits the span, not the a that carries the cta class. Elements nest.
The DOM is live
The DOM is the browser's tree built from the HTML, and JavaScript can change it after the page loads.
Source (what the server sent)
Elements (live DOM)
This is the View source vs Elements difference you'll meet in DevTools.
The <script> tag
<!-- inline: the code is right here -->
<script>console.log('hi')</script>
<!-- src: the code is in a file the browser fetches -->
<script src="https://example.com/analytics.js"></script>
Where a script sits matters. One in <head> runs before the body exists. One at the end of <body> runs after the page content. This is what sets up load order.
2 CSS: selectors only
Skip styling entirely. Selectors are how CSS, JavaScript and DevTools find elements on a page.
| Selector | Meaning |
|---|---|
#id | Element with that id |
.class | Elements with that class |
[data-track="cta"] | Elements with that attribute value |
.nav a | Any link inside .nav (descendant) |
:not(.x) | Exclude elements with class x |
.cta, .cta * | The .cta element and everything inside it |
Demo: selector tester
Type a selector. Matches get highlighted below, like Ctrl+F in the Elements tab.
css-1x9kq (React, CSS modules, Tailwind builds) change on every deploy. Don't rely on them. Prefer a stable id or a data-* attribute.
display:none and visibility
A hidden element is still in the DOM. It just isn't shown.
3 JavaScript: enough to read and test
Every example is typed live in a Console. Pick a topic to load its snippet, then press Run (or Ctrl+Enter). You can edit the code.
| Topic | Min | What to cover |
|---|---|---|
| 2 | Print a value to the Console. The tool for checking every step that follows. | |
| 3 | let, naming a value so it can be reused, and reassigning it. | |
| 3 | Text in quotes vs plain numbers, typeof. Gotcha: "5" + 5 gives "55", because values read from a page usually arrive as strings. | |
| 2 | A list in square brackets, positions start at 0, .length, .push() to add an item. | |
| 3 | Define, call, pass in a value. return hands a value back, console.log only prints it. | |
| 3 | document.querySelector() to find a button, addEventListener('click', …) to react. Run it, then click the demo button. | |
| 4 | See below. |
Console
Demo button for the event listener topic:
Storage: three places a browser keeps things
localStorage: stays until cleared.sessionStorage: cleared when the tab closes. Both usesetItem/getItemand both store strings.- Cookies via
document.cookie: they have an expiry and are sent to the server with requests.HttpOnlycookies can't be read by JavaScript.
This sets up the Application tab.
4 DevTools
The longest block, because this is where you'll spend your working life. Open it with F12 or Ctrl+Shift+I.
- Right-click, Inspect, then read the element's attributes.
- Right-click the node, Copy → Copy selector.
- Test a selector first: press Ctrl+F in the Elements panel and paste it. It shows "1 of N" matches.
- View source = what the server sent. Elements = the live DOM after JS ran.
- Run
console.logand the Section 3 snippets. document.querySelectorAll('.cta')counts matches for a selector.document.cookielists readable cookies.- Read red errors: a JS error can stop other scripts.
- Tick Preserve log and Disable cache.
- Filter
collectfor analytics hits. - Open a GA4 request and read the payload:
en(event name),tid(measurement ID),ep.(custom event params). - A request blocked by an ad blocker shows red, and the hit never reaches GA4.
- Request types:
fetch,ping/beacon (fire-and-forget hits).
Sample GA4 request payload
https://www.google-analytics.com/g/collect? v=2 tid=G-XXXXXXX ← measurement ID en=sign_up ← event name ep.method=email ← custom event parameter
- Lists every loaded file. Open any third-party script to see its code.
- Click a line number to set a breakpoint that pauses code there.
- Keep it light: the least used tab for marketers.
- Cookies:
_ga(GA client ID),_gcl_au(Google Ads),_fbp(Meta), plus consent cookies. - localStorage and sessionStorage.
- Clear site data simulates a brand-new user.
5 Wrap-up: one end-to-end walkthrough
Click the button once and follow the trail through each DevTools tab.
- Console: the click listener's output
- Elements: the selector that matches the button
- Network: the hit that was sent
- Application: the cookie that identifies the user