Safe methods to modify AdSense responsive ad code

Advertisement
Google AdSense
Google AdSense / Google

These are safe methods you can use to modify your Google AdSense responsive ad code to implement on your responsive web design. You can specify a general shape, expandable width with fix height, exact size per screen width, or, hiding an ad unit on specific screen width.

After completed the migration from HTTP to HTTPS few days back, I noticed that there was javascript file loaded from non-secure http on Barzrul.com causing the site to not load properly. Upon checking the source code with Chrome Developer Tool, found out that I was using below javascript to render the AdSense ad code.

So, to remove this line of javascript, I need a new code for the AdSense to work. While searching, I found this page which explains how can I effectively modify AdSense responsive ad code. Let’s dive in.

Advertisement

Safe methods to modify AdSense responsive ad code

The following are 4 methods to modify AdSense responsive ad code to make it works as intended. Don’t worry, all these methods are guarantee safe as they are provided by Google itself.

1. Specify a general AdSense ad shape

You can modify the “data-ad-format” to specify the general shape (horizontal, vertical, and/or rectangle).

2. Specify an expandable AdSense ad width and a fixed height

You can modify the “style” to specify an expandable width and a fixed height.

3. Specify an exact AdSense ad size per screen width

You can modify the ad code to specify the exact size for your ad unit via CSS.

4. Hiding an AdSense ad unit

You can modify the ad code to show ads for certain screen sizes via CSS.

Which method do you prefer for your blog or website? Let me know in the comment below.

Advertisement
Articles you may like
Leave your comment

Leave a Reply

Barzrul Tech uses cookies to ensure you get the best experience while browsing the site.Read more >>
+
Share via
Copy link
Powered by Social Snap