ping
Send tracking pings to specified URLs when a link is clicked. A transparent, declarative alternative to redirect-based or JavaScript click tracking.
Overview
The ping attribute on <a> elements sends background POST requests to one or more URLs when the link is clicked. The user navigates directly to the link's href destination while the tracking requests are sent asynchronously — no redirect delay, no JavaScript required.
Applies to: <a>
Values
| Value | Behavior |
|---|---|
| Single URL | Sends one POST request on click |
| Space-separated URLs | Sends a POST to each URL on click |
Basic Usage
Add one or more tracking URLs to the ping attribute. The browser sends POST requests to each URL when the link is clicked.
Practical Examples
Common use cases include tracking outbound links, measuring CTA effectiveness, and notifying analytics services of navigation events.
What the Browser Sends
The POST request includes headers that identify both the page the user was on and the destination they are navigating to.
Comparison with Other Tracking
The ping attribute competes with two established tracking patterns: redirect URLs and JavaScript click handlers. It has advantages over both.
| Approach | User Delay | Requires JS | Visible in Source | Works if JS Fails |
|---|---|---|---|---|
| Redirect tracking | Yes (extra hop) | No | URL is obscured | Yes |
| JS click handler | Minimal | Yes | Buried in scripts | No |
ping attribute | None | No | Yes (in HTML) | Yes |
Transparency Advantage
Unlike JavaScript-based tracking, the ping attribute is visible in the page source. Privacy-conscious users, browser extensions, and auditing tools can see exactly which URLs receive tracking pings. This transparency was an intentional design goal of the specification.
Accessibility
- The
pingattribute has no effect on accessibility. Screen readers announce the link normally based on its text content andhref. - The attribute does not change the link's visible destination or behavior from the user's perspective.
- Keyboard activation (Enter) triggers the ping just as a mouse click does.
Limitations
- Firefox disables
pingby default. Thebrowser.send_pingspreference isfalsein Firefox, making the attribute unreliable for cross-browser analytics. - Privacy-focused browsers and extensions (uBlock Origin, Brave) may block ping requests entirely.
- The POST body is just the string
PING— you cannot send custom data. Any context must be encoded in the URL query string. - Only works on
<a>elements. It does not apply to<button>,<form>, or programmatic navigation. - The
Ping-Fromheader is omitted in cross-origin requests when the referring page uses HTTPS and the ping URL uses HTTP (downgrade scenario).
See Also
referrerpolicy— control what referrer information is sent with requestsrel— link relationship types includingnoopenerandnoreferrer<a>— the anchor element