Implementing Google Ads but trying to serve one of two ad script depending on the $(document).width().
Read up and searched around as best I could, and what I've got thus far doesn't appear broken (no visible errors) other than it doesn't actually insert a Google Ad. (yup, misses the whole point there!)
First I'm setting the area to hold the ad:
<div id="google-ad"></div>
Followed by logic to determine the document width, and insert the necessary Google Ad script:
if ( $(document).width() < 728 ) {
$("#google-ad").html('<script type="text/javascript"><!--google_ad_client = "ca-pub-GOOGLE-ID";/* AD NAME HERE */google_ad_slot = "GOOGLE-NUMBER"; google_ad_width = 320; google_ad_height = 50;//--><\/script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><\/script>');
} else {
$("#google-ad").html('<script type="text/javascript"><!--google_ad_client = "ca-pub-GOOGLE-ID";/* AD NAME HERE */google_ad_slot = "GOOGLE-NUMBER"; google_ad_width = 728; google_ad_height = 90;//--><\/script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><\/script>');
});
In theory, I think this works but it's actually not working. So, I'm certainly doing something incorrectly. Would welcome any help or direction.
Thanks.