A user (Gregg Man from the Google Chrome developer team) noticed the issue because he had browser developer tools open and it appeared the site was trying to play audio, a common annoyance, with the debug message "The AudioContext was not allowed to start".
Deeper investigation though showed that the script was not in fact trying to start audio, but rather calling numerous browser APIs in order to create a unique "fingerprint" for the user's computer. This means that even with cookies blocked, the ad server can track the user.
A sneaky ad on the internet is not news. In this case though, the site claims that "Every single ad to appear on any of our sites is vetted by the operations team." And lead architect Nick Craver soon observed that "We are aware of it. We are not okay with it. We're trying to track down what is doing it and get that mess out of here. We've also reached out to Google to enlist their support."
StackOverflow has previously stated that its policy "includes but is not limited to running only static, non-animated banner[s], keeping all ads relevant to software development, not participating in real-time bidding or selling our inventory to ad networks. We are not selling user data or targeting ads to you based on any personally identifiable user data."
An updated policy that covers collecting personal information, monitoring account activity and using profile information and job history to target advertising is here.
This ad, though, was passed through from Google and although it looks like a static banner advertising Microsoft Azure with a link, the fingerprinting code is running in the background.
Fingerprinting is a common technique. A 2018 study of the usage of sensor APIs on the mobile web found that "a vast majority of third-party scripts are accessing sensor data for measuring ad interactions, verifying ad impressions, and tracking devices," rather than for the intended purpose.
The tracking, advertising and monetization story on the internet is convoluted beyond measure, driven by huge global revenue involved, estimated at $298.1bn in 2019 by WARC. Fingerprinting code is not necessarily used to track users; the popular library https://fingerprintjs.com/, for example – which may or may not be the one used – sells itself as a fraud detection measure, enabling websites to detect multiple clicks from the same device used for such things as click fraud, vote fraud or suspicious purchasing patterns.
In other words, the tracking script might be there not so much to track the user, as to protect the advertiser from fraud. There is no way of telling.
Ad-blocking is a solution to script issues in many cases, including this one, though ad-blockers too have downsides, including disrupting the business model of sites that you value, and modifying the source of web pages on the fly. Another approach is to block selected DNS requests using a tool like pi-hole, but this is another example of breaking the internet in an attempt to fix it.
The end result is calls to media and sensor APIs that are nothing to do with media or sensors, scripts that track you without cookies, and a site that is trying to advertise responsibly delivering a privacy-busting script. ®