HTMLImageElement: attributionSrc property

Deprecated
To be removed

This feature is pending removal from browsers. Using it now may lead to broken functionality in future updates. Following the announcement that Chrome will maintain its current approach to third-party cookies, Chrome decided to withdraw certain Privacy Sandbox features including the attribution reporting API.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

The attributionSrc property of the HTMLImageElement interface that you want the browser to send an Attribution-Reporting-Eligible header along with the image request. It reflects the <img> element's attributionsrc content attribute.

See the Attribution Reporting API for more details.

Value

A string that is either empty or a space-separated list of URLs. For the interpretation of this attribute, see the HTML <img> reference.

Examples

Setting an empty attributionSrc

html
<img src="advertising-image.png" />
js
const imgElem = document.querySelector("img");
imgElem.attributionSrc = "";

Setting an attributionSrc containing URLs

html
<img src="advertising-image.png" />
js
// encode the URLs in case they contain special characters
// such as '=' that would be improperly parsed.
const encodedUrlA = encodeURIComponent("https://a.example/register-source");
const encodedUrlB = encodeURIComponent("https://b.example/register-source");

const imgElem = document.querySelector("img");
imgElem.attributionSrc = `${encodedUrlA} ${encodedUrlB}`;

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also