Knowledge Base · Content & monetisation
Publisher ads on a static site: a service worker, a head tag and the install check
The symptom
The network's dashboard reported the installation as incomplete although the code had been pasted in.
What was actually wrong
The install consists of a service worker at the web root (the path and scope are mandatory, not a suggestion), a script tag in the head carrying the zone identifier, and the registration call in the page. A stale service worker from a previous zone makes the check fail even though the new tag is present.
The fix
The current service worker file was copied to the root of the served directory, the head tag was placed immediately after the opening <head>, the registration call was added, and both the served file and its zone value were read back from the live origin — the dashboard's check then passed.
What we took away
Ad-network installs have a version: when a dashboard reissues credentials, the previously deployed file is a trap. Read back what the live origin actually serves — the zone identifier included — instead of trusting the file you just copied.