Sources indicate that when an agency takes over a local client's website, the analytics are usually the first thing that turns out to be wrong. The numbers in the report look odd, and the reason is almost always in the HTML: a GA4 tag pasted twice, a Universal Analytics tag that has not sent data in years, a second GA4 property that a previous freelancer set up on one page, or a chat widget and a heatmap tool that nobody remembers adding.

It has been revealed that none of this is visible by looking at the site. You have to read the source of every page, and on a 40-page site nobody does that by hand.

This tutorial builds a small Python script, standard library only, that reads a sitemap, fetches every page and reports:.

I ran it for real against a small fictional site on localhost, so every line of output below is real output from the script. The site, "Harbor Lane Dental", is made up for this tutorial, every tag ID is invented, and the vendor hosts use the reserved .example domain. The script only parses HTML, so it never contacts any of the third-party hosts.

Disclosure: I work on Appie.run. Two free sitemap tools on appie.run are mentioned near the end; the script does not need them.

Three reasons, in the order clients usually feel them:.

In a recent development, this script is an inventory, not a privacy or consent review. It tells you what the HTML loads. Whether each tag should be there, and under what consent setup, is a decision for the client and whoever advises them.

Sources indicate that it reads the HTML the server sends. That has two limits worth knowing before you trust the output:.

For a typical small business site built on a theme or page builder, most tags are pasted straight into the HTML, so the inventory still catches most of what matters.

It has been revealed that the fictional site has five pages: home, services, booking, one blog post and contact. The "before" version has the problems I see most often on inherited client sites:.

The "after" version fixes all of that, except that the blog post deliberately carries no ads pixel, which gives us one warning to discuss.

Recent findings suggest that the fixture is a tiny http.server app on port 8504 that serves a sitemap and five pages. It takes before or after as its argument.

Sources indicate that save this as tag_inventory.py. It needs Python 3.9 or later and nothing outside the standard library.

A few design choices worth explaining:.

πŸ“Œ Read also:

β†’ Read original article