I didn’t know this was a thing until Stefan Judis’s post:
<a href="https://www.stefanjudis.com/popular-posts/" ping="https://www.stefanjudis.com/tracking/">Read popular posts</a>
You give an anchor link a URL via a
ping attribute, and the browser will hit that URL with a web request (a literal PING) when clicked. The headers have a
ping-to key with the
href value of the link.
Why? Data. Wouldn’t it be nice to know what off-site links people are clicking on your website?
Even if you have Google Analytics installed, you don’t get that data by default. You’d have to write something custom or use something like their autotrack plugin with the
outboundLinkTracker. Whatever you do, it is non-trivial, as in order to work, it has to:
- Prevent the default action of the link (going to the website)
- Track the event (send a ping somewhere)
- Then tell the browser to actually go to the website (window.location = …)
Presumably, with the