Adding AdSense Auto ads to your WordPress site

Google has announced, today, a new style of AdSense ad – the “Auto ad”. Using machine learning, the code will insert adverts into your site where it things they will be most relevant.

Auto ads balance revenue and user experience by delivering the right ad at the right time to your visitors.

They can even be added side-by-side with your existing, fixed, AdSense advert. And it’s really easy to add these to your WordPress site.

Head to your AdSense account and find the Auto ads option under ‘My Ads’.  Configure Auto ads appropriately (you can choose what types of adverts that they’ll use) and then grab the JavaScript code that is generated.

Open up your theme’s function.php file and then insert the following code…

function google_autoads() {
?>
[[insert your AdSense script here]]
<?php
}
add_action( 'wp_head', 'google_autoads' );
view raw function.php hosted with ❤ by GitHub

Finally, replace `[[insert your AdSense script here]]` with the JavaScript that Adsense gave you earlier and… that’s it. Auto ads should now appear on your site.

One response

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from David Artiss

Subscribe now to keep reading and get access to the full archive.

Continue reading