Responsive Ads: User Agent or Screen Resolution?

's Avatar


09 Oct, 2017 04:12 PM

Do AdvertServe responsive ads use User Agents to swap out ad sizes? We typically use media queries to do this - user agent sniffing is pretty unreliable.

  1. Support Staff 1 Posted by Mike Cherichett... on 09 Oct, 2017 05:13 PM

    Mike Cherichetti's Avatar


    AdvertServe does use user agent detection, which is very accurate. We don't use simple pattern/regex detection like most detection libraries. Instead we use a bayesian algorithm that can infer the device type of even previously unknown agents by comparing them for similarities to other known agents. We also detect many bots this way. It works quite well though because honestly the only time we need to update our detection database is when totally new browsers or rendering engines are released.

    That being said, yeah, it obviously falls short if you're hoping to just be able to resize your browser window on desktop and have it swap the ads out for mobile ads. Although you can get around that by using a user agent switching plugin for your browser. Some users find that to be an annoying extra step, but the whole point of our responsive zone support is to get the job done with as minimal of coding as possible.

    If you want to have more media query like control over the ads that is possible to achieve with some extra coding if you use our AJAX zone code.

    You can see there's a mini-framework that lets you define breakpoints for the ad zones like this:

      tagid: 'top_banner', alias: '/', type: 'banner', pid: 0, resolutions: [
        { minWidth: 1000, zid: 39 },
        { minWidth: 800, zid: 40 },
        { minWidth: 0, zid: 41 }
      tagid: 'side_banner', alias: '/', type: 'banner', pid: 0, resolutions: [
        { minWidth: 1000, zid: 27 }

    So what happens here is the top zone has 3 different sizes that will swap out at 800px and 1000px while the side zone only appears at 1000px and above.

    This is something we're considering to make an official feature of our AJAX code, but for now it's unofficial and may not be compatible with some features such as the options to lazy-load a zone only when it's in the browser viewport.


  2. Mike Cherichetti closed this discussion on 16 Oct, 2017 04:08 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

03 Aug, 2020 08:33 PM
22 Jun, 2020 06:51 PM
07 Feb, 2020 05:39 PM
10 Dec, 2019 05:28 PM
09 Sep, 2019 02:07 PM

Recent Articles