开发者

Tracking pixel (transparent GIF) as a background-image in a stylesheet?

开发者 https://www.devze.com 2023-04-07 00:43 出处:网络
Anyone know if adding a tracking pixel (just a transparent GIF with some logging going on at the server that\'s sending out the GIF) as a background-image in a linked stylesheet will work the same as

Anyone know if adding a tracking pixel (just a transparent GIF with some logging going on at the server that's sending out the GIF) as a background-image in a linked stylesheet will work the same as if it was a regular <img> on a page?

From a simple test I did in Chrome's network inspector it looks like it's just pulling images from local cache if I go into the location bar and hit enter. If I actually click Reload then I see it go out to the server and get back a 304. And if I shift+reload it'll force it to go back to the server for real and I get 200s.

But, it looks like it's the same behavior for the <img> images on the page as well, so then the behavior as a background-image should match the behavior as if it was an 开发者_C百科<img>


It should work exactly the same way. But tracking pixels are not decorative, or are specific to a single page, so it is easier to put an img tag in the HTML and a little more reliable, it will work for text browsers, etc.


Having a tracking pixel called via CSS would be possible, but there would be some challenges compared to using a tracking pixel in HTML:

  • Tracking pixels commonly have visitor data detected by JavaScript (monitor size, for instance) added to the pixel's URL. JavaScript would be unable to (easily) do this if the pixel was called via stylesheet.
  • When in the page source, the tracking pixel can be at the bottom of the page and be modified by code that executes first. This would be difficult to do in a single-pixel-call via CSS.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号