Home » Blog » Cybersecurity » Cybersecurity » How To Display Google AdSense Advertisements To Only Search Engine Visitors On WordPress
Search Engine Visitors

How To Display Google AdSense Advertisements To Only Search Engine Visitors On WordPress

AdSense Advertisements For Search Engine Traffic

During the process of monetizing a WordPress blog or website many webmasters (owners, admins, whomever) take a tactical approach in order to leverage earnings by strategically placing Google AdSense advertisements which are only visible to organic search engine traffic (opposed to all visitors). Many bloggers and webmasters acknowledge that organic visitors from Google are more likely to click and respond to Google AdSense advertisements.

Besides displaying advertisements for only incoming search traffic, there are many valuable procedures which can be accompanied by displaying ads for search engine traffic in order to keep website readers and visitors satisfied.  Keep in mind that sometimes too many advertisements can be a bad thing, in this case using our supplied snippet below can keep your direct and referred traffic happy whilst providing advertisements for visitors whom are statistically more likely to click the advertisements. The snippet can also be used to maintain the amounts of advertisements on your website, keeping ads organized, and only displaying AdSense when necessary.

There are many WordPress plugins and essentially different ways to display Google AdSense ads for search engine traffic only, but we find using a simple PHP function supplied by Scratch99 is better for performance, and advertisements can strategically be placed anywhere without the limitation some plugins possess.

Display AdSense To Search Engine Traffic Only
Google AdSense Advertisement Examples

How to display advertisements to only organic visitors

Down Copy and paste the snippet below into your functions.php file

function scratch99_fromasearchengine(){ $ref = $_SERVER['HTTP_REFERER']; $SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.'); foreach ($SE as $source) { if (strpos($ref,$source)!==false) return true; } return false; }


Down Copy and paste the snippet below wherever you wish to display your advertisements

Replace INSERT ADSENSE CODE HERE with an individual Google AdSense code


if (function_exists('scratch99_fromasearchengine')) {
  if (scratch99_fromasearchengine()) {

Sean Doyle

Sean is a tech author and engineer with over 20 years of experience in cybersecurity, privacy, malware, Google Analytics, online marketing, and other topics. He is featured in several publications.

More Reading

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

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

How To Start A WordPress Newsletter

How To Add A WordPress Login Form Using Widgets (Shortcode)

What do SSL certificates actually do?