Home / Tools / Google Ad Manager
✦ Google Ad Manager

GPT size mapping generator

Pick which ad sizes may show at each viewport width, see the result on common screens, and copy the googletag.sizeMapping() code for your Google Ad Manager slot.

Breakpoints

Start from

Each row reads: when the browser is at least this wide (and tall), the slot may show these sizes. Use height 0 to match on width only, and a 0 x 0 row as the fallback for the smallest screens.

Size mapping code


          

Breakpoints are sorted from largest to smallest. GPT uses the largest one that fits the browser, width first, then height.

Slot sizes for defineSlot()


          

Every size used above. GPT falls back to the defineSlot() sizes when the mapping can't be applied.

What shows at each width

Boxes are drawn to scale against the window width. Red means the ad is wider than the screen.

Checks

Full slot example

            

Runs inside googletag.cmd.push(), before googletag.enableServices(). Generate the whole tag with the GPT tag generator.

How GPT size mapping works

A size mapping tells Google Publisher Tag which ad sizes a slot may request at which browser size. You build it with googletag.sizeMapping(), add one addSize(viewport, sizes) call per breakpoint, finish with build(), and attach it with slot.defineSizeMapping(mapping).

When the page loads, GPT reads the size of the browser window and uses the largest breakpoint that fits, comparing width first and then height. A window 900px wide with breakpoints [1024, 0], [768, 0] and [0, 0] gets the [768, 0] sizes.

An empty list, [], means no ad may serve at that size, which is how you hide a slot on mobile. The [0, 0] row matches every window, so it acts as the fallback for screens smaller than your other breakpoints. If the mapping has an error, or the window size can't be read, GPT uses the sizes from defineSlot() instead, so list every mapped size there as well.

GPT reads the window size when it makes the ad request, so test each breakpoint by loading the page at that width rather than by resizing a page that already shows ads.

Frequently asked questions

Does the order of addSize() calls matter?

Google's docs say the order of viewport sizes in the mapping sets their priority, and that the sizeMapping() builder orders them from largest to smallest automatically. GPT then uses the largest breakpoint that fits the window, width first, then height. This tool outputs them largest first, so the code reads the same way GPT applies it.

Do I need a [0, 0] breakpoint?

Add one. Without it, a window smaller than your smallest breakpoint matches no row. Add [0, 0] with your mobile sizes, or [0, 0] with [] to show no ad there.

How do I hide an ad slot on mobile?

Map the small breakpoint, usually [0, 0], to an empty list []. No ad can serve at that window size. Pick none (hide) in the tool to get it.

Should the viewport height be 0?

Usually yes. A breakpoint such as [1024, 768] only matches windows at least 768px tall, so a short laptop window falls through to a smaller breakpoint. Use 0 unless you really want to filter on height.

Do the defineSlot sizes still matter with a size mapping?

Yes. If the mapping has an error or the window size can't be read, GPT uses the sizes passed to defineSlot(). List every size from the mapping there, which the tool gives you ready to copy.

Related guides

More free tools