Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Missing http-referrer for img tracking pixels on iOS

Open ckbo3hrk opened this issue 9 years ago • 7 comments

Type of issue

[x] Bug ?

Description

During tests on iOS we've noticed that http request for tracking pixel in rendered creatives doesn't contain referrer http-header and that may cause a discrepancy in statistics. The referrer header is absent at least for Safari and Chrome mobile browsers. After some tests I've found that approach with rendering creative in iframe with iframe.srcdoc solves this issue. I beleive that this issue may affect any of ad platforms that relying on http-referrer information from theirs tracking pixels.

Here is POC that fixes this issue: /src/prebid.js:renderAd

if (doc === document || adObject.mediaType === 'video') {
    utils.logError('Error trying to write ad. Ad render call ad id ' + id + ' was prevented from writing to the main document.');
} else if (ad) {
  if (doc.defaultView && 'srcdoc' in doc.defaultView.frameElement) {
    doc.defaultView.frameElement.srcdoc = ad;
  } else {
    doc.write(ad);
    doc.close();
  }
  setRenderSize(doc, width, height);
}

Steps to reproduce

  1. Open http://jsfiddle.net/ckbo3hrk/u9qq2ee1/ url with Chrome or Safari on IOS
  2. In intercepted requests (I used fiddler with proxy option enabled in order to intercept traffic from mobile device) there is no http referrer header for http://cpm.metaadserving.com/win?i=UBY6QS45GBA_0 request
  3. Open http://jsfiddle.net/ckbo3hrk/baqedx28/ url (it uses an updated version of prebid.js with proposed solution) with Chrome or Safari on IOS
  4. Http referrer header is presented in requests as expected

Platform details

IOS 10.2.1 on Ipad Air, Chrome 56.0.2924.79, Safari 10.0, Prebid 0.17.0

ckbo3hrk avatar Feb 09 '17 11:02 ckbo3hrk

Great stuff! I'm all for using HTML 5 when we can. Want to open up a PR?

How did you use a mobile device to test with fiddler? Was it emulation or a real device?

mkendall07 avatar Feb 10 '17 17:02 mkendall07

Want to open up a PR?

Once I've done some in-house tests I'll open up a PR.

How did you use a mobile device to test with fiddler? Was it emulation or a real device?

I did the tests on a real device (IOS 10.2.1 on iPad Air). I configured the fiddler on PC as a proxy then configured the ipad to use this proxy.

ckbo3hrk avatar Feb 10 '17 21:02 ckbo3hrk

Very nice and important. i'm going to test .0.19 build adding srcdoc i can see how this issue is one of the major discrepancy factors.

mercuryyy avatar Feb 14 '17 20:02 mercuryyy

It looks like Firefox doesn't support http referrer sending for srcdoc-placed sub-resources. Maybe we should leave the old rendering aproach for Firefox.

ckbo3hrk avatar Feb 16 '17 16:02 ckbo3hrk

@ckbo3hrk Do you have an updated snippet to use srcdoc only for supported browsers ?

mercuryyy avatar Feb 16 '17 16:02 mercuryyy

@mercuryyy I think the snippet above does that.

mkendall07 avatar Feb 17 '17 15:02 mkendall07

This is in master.

mkendall07 avatar Apr 01 '17 00:04 mkendall07