3 ms·
Does anyone want the ping attribute? It seems like JS-based trackers using sendBeacon are the better option for analytics.
by Eridrus 8y ago
Does anyone want the ping attribute?
It seems like JS-based trackers using sendBeacon are the better option for analytics.
- geocar 8y agoYes. I implement these kinds of trackers, and right now, my choices look like this: 1. Use a redirect: <a href="trackingurl?redirect=target">link</a> However this is difficult to implement securely, so most people don't. It's also ugly: The user sees tracking urls in the URL bar and each need to load in turn, redirecting to the final target. 2. Use JavaScript: <a onclick="navigator.sendBeacon('trackingurl')" href="target">link</a> This seems to be your suggestion. This requires JavaScript and the JavaScript could be doing other things, like a global mousedown handler which could interfere with it. Many tracking "solutions" have to be carefully written to avoid this kind of interference, which makes development hard to implement as well. The risk is that people's websites' break. 3. Use CSS: <style> a:active{background-image:url(trackingurl) !important;}; </style> This "works" but it's sneaky, and it's even more likely that multiple tracking "solutions" will interfere with each other using this method. It might also break the publisher's site if they intended the selector for another purpose. 4. Use ping: <a ping="trackingurl" href="target">link</a> Now looking at all four options, I'd definitely much rather use ping= because (a) it's likely to be implemented correctly, (b) it's unlikely to break other scripts/styles on the page, and (c) it's not sneaky; the effects are implementation are transparent. However I appreciate to some people "anyone" might not include the people who write the content you're reading -- after all, if you don't care about them, then surely there isn't "anyone" who wants this, but this is immature. These are most certainly people, and these are the people that want this: People who know about other methods and have thought about the risk/reward of using them.
- chrismeller 8y agoI absolutely think the ping attribute is preferable, but several of your solutions are to avoid conflicting with other tracking solutions that are in place already. How would you address that with ping attributes?
- geocar 8y agoThe ping attribute stores a space-separated list of urls.
- Eridrus 8y agoFWIW, I asked this since I've built client-side ads/analytics code before and I very much prefer JS-based solutions, since you can sort out the difficulties of dealing with interfering scripts once, put it in a library and still have control of what is going on. But I guess it does provide a simple mechanism for folks who would otherwise use a redirect and don't want to deal with the complication, so thanks for the insight.