javascripthtmltwitter-bootstrapresponsive-designadsense

How to make GoogleAdSense (Custom Search Ads) to be responsive (bootstrap)?


We have google ads implemented in our website. Recently we changed the entire website to responsive design. So I was looking at options from google and found out that google has an api for responsive design. I looked at ways to implement it.

What I found from documentation and verious examples posted over internet was to get responsive ads using this

 <script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" type="text/javascript"></script>
 <div id='GoogleAdParentContainer'>
    <ins class="adsbygoogle" style="display: block" data-ad-client="ca-pub-xxxxx" data-ad-slot="yyyyyyyy" data-ad-format="auto"></ins>
 </div>
    <script type="text/javascript">
    (adsbygoogle = window.adsbygoogle || []).push({});
</script>

I completely understand how the above code works and I tested it and its absolutely fine - but my problem is we were using custom ads from google where we were passing the search string, etc to query the google ads. We use custom ads with query since our website is very big. Our script goes like this -

    //Our existing code with custom search query to get relevant ads
    <script type="text/javascript" charset="utf-8">
       var pageOptions = { 'pubId': 'pub-id','query': 'toy search in new york'};
       var adblock1 = 
       { 
         'container': 'adcontainer1',
         'number': 4,
         'width': '700px',
         'noTitleUnderline': true 
       };
      _googCsa('ads', pageOptions, adblock1);
    </script>

Now I dont know how to make this responsive - I could not find any documentation. Please help me with this !!


Solution

  • It is so simple:

    replace ---->>> 'width': '700px'

    with ---->>> 'width': '100%'

    enjoy your google csa!!!

    woody