2025-03-25 02:53:05
Advertising is one of the ways to generate revenue from a WordPress website, and targeting the right audience can effectively increase the click-through rate (CTR) and advertising revenue. One of the proven strategies that works well is displaying ads specifically for visitors coming from search engines like Google or Yahoo.
Based on our research and experience, we have found that users who visit the website from search engines are more likely to click on ads than regular users. Additionally, displaying targeted ads helps reduce the number of ads shown to regular visitors, improving the overall website experience, reducing annoyance, and increasing the chances of users following your content in the long term.
To do this, you will need to add special code to your WordPress website. But don't worry, you can easily do it using the WPCode plugin.
If you don't have ads on your website yet, please refer to the guide on how to add Google AdSense to WordPress. After that, install and activate the WPCode plugin, which allows you to add custom code to your website without directly editing the code files.
Go to Code Snippets » + Add Snippet, then select ‘Add Your Custom Code (New Snippet)’ and copy the code below into the Code Preview box.
$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) {
setcookie("sevisitor", 1, time()+3600, "/", ".yourwebsite.com");
$sevisitor=true;
}
}
function from_searchengine(){
global $sevisitor;
if ($sevisitor==true || $_COOKIE["sevisitor"]==1) {
return true;
}
return false;
}
Note: Don't forget to change .yourwebsite.com to your own domain.
Then select 'PHP Snippet' in Code Type and activate the code by pressing the Save Snippet button.
Create a new snippet and copy the following code into it.
<?php if (function_exists('from_searchengine')) {
if (from_searchengine()) { ?>
INSERT YOUR AD CODE HERE
<?php } } ?>
Note: Replace INSERT YOUR AD CODE HERE with your Google AdSense ad code.
Then select 'PHP Snippet' and click Save Snippet.
You can choose to use the Shortcode method to insert advertisements into the desired positions on your website. Simply copy the Shortcode and add it to Widgets, Sidebar, or Post/Page as needed. For example, if you want to display the advertisement in the Sidebar, go to Appearance » Widgets and add the Shortcode Block.
After all the settings are configured, WordPress will start displaying ads specifically for visitors coming from search engines and will store their cookies for one hour. If users bookmark the website and return later, these ads will not be shown to them again.
Displaying ads specifically for visitors from search engines is a strategy that effectively increases CTR and ad revenue. This method helps keep your website from being cluttered with too many ads and also creates a better user experience for regular visitors.
2025-01-10 10:12:01
2024-05-31 03:06:49
2024-05-28 03:09:25
There are many other interesting articles, try selecting them from below.
2024-04-23 09:24:24
2025-01-24 02:47:13
2024-04-25 09:36:08
2023-12-25 02:43:29
2024-12-03 03:54:47
2024-10-10 09:46:13
2023-10-10 11:38:54
2024-06-17 04:16:51