Jump to content

Responsive: Showing ads conditionally


bdamage

Recommended Posts

On my responsive site the appropriate CSS is selected based on media-querys to show either the mobile-only zone or the desktop-only zone. I did this using a wrapper appropriately with "display:none" set for the hidden one. But this means 2 ads are always pulled from the server. When I'm using Adsense are they being counted as 2 separate ads each time? Won't Google forbid this?

I suppose what I'm asking is - is there a smarter way to set this up so only the zone which will appear is loaded, based only on the CSS media-query (or other) way ?

Link to comment
Share on other sites

Hi @bdamage,

Yes, I think you will want to do this another way - if you're always loading the banners, but then just hiding one, then that will probably record an impression for each banner, and probably Google (and most other services) won't approve of you loading, but hiding, their banners.

Presumably, your wrapper can determine (using JavaScript?) if you're showing the page to a mobile user or a desktop user, and currently sets the display property based on this? If so, rather than setting a display property, why not either load or not load the invocation tag?

That way, you will only load the zone that's appropriate.

Link to comment
Share on other sites

Yes, that's it. A vastly simplified, but still non-working, version of what I'm trying:

<style>
	/* Desktop */
	@media screen and (min-width: 600px) {
		.desktop {
			display:block;
		}
		.mobile {
			display:none;
		}
	/* Mobile */
	@media screen and (max-width: 600px) {
		.desktop {
			display:none;
		}
		.mobile {
			display:block;
		}
	}	
</style>

<div class="desktop">
	<ins data-revive-zoneid="1" data-revive-id="999999999"></ins>
</div>				

<div class="mobile">
	<ins data-revive-zoneid="2" data-revive-id="999999999"></ins>
</div>				

Any tips on how to just execute the relevant <ins ...> part greatly appreciated. Thanks.

Link to comment
Share on other sites

I think what it being suggested here is that you make a decision about which div to include - perhaps server side. So if you are using PHP you would make a decision about which div to render and only render the one you want to use based on the user device.

Alternatively you could do it client side with javascript - make the decision at run time, inline, and append the chosen invocation code. Something like $("#myad").append('<ins blah blah blah'>);

The trick would be to do that BEFORE the async call executes and looks for active zones.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...