Skip to content

Instantly share code, notes, and snippets.

@krogsgard
Last active December 10, 2015 07:38
Show Gist options
  • Save krogsgard/4402068 to your computer and use it in GitHub Desktop.
Save krogsgard/4402068 to your computer and use it in GitHub Desktop.
Responsive Ad Slots for Google Ads. Load different ad slots depending on the window size. Doesn't currently work on resize.
var window_innerwidth = window.innerWidth;
if ( window_innerwidth < 630 ) {
GA_googleFillSlot( "Skinny-Ad" );
} else if ( window_innerwidth >= 630 && window_innerwidth < 728 ) {
GA_googleFillSlot( "In-Line-Ad" );
} else if ( window_innerwidth >= 728 && window_innerwidth < 950 ) {
GA_googleFillSlot( "Skinny-Ad" );
} else {
GA_googleFillSlot( "In-Line-Ad" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment