WordPress Plugin for Simple Google Adsense Insertion/Integration
Categories: Wordpress Plugin
Easy to use Wordpress plugin to insert Google Adsense to your posts, pages and sidebar by using a trigger text or calling the php function.
There are many plugins and services which can add Google Adsense to your WordPress site. However I found that even though something like Adsense Manager or Adsense Deluxe provides a lot of customizable options, it can be overwhelming and isn’t really simple enough for people who are new to WordPress or for people who simply want to insert Google Adsense to their site in a few clicks.
I found that most of the time I only use two or three types of Google Adsense units in various places and posts throughout my sites. Google’s Adsense policy mentions to not have more than three adsense block in one page anyway. That’s why I wrote my own Simple Adsense Insertion Plugin for WordPress, to focus on having 1-3 Google Adsense codes saved and use them where ever I want on my site by inserting a simple trigger text to my posts,pages and sidebar.
Installation
1. Unzip and Upload the folder ‘WP-Simple-Adsense-Insertion’ to the ‘/wp-content/plugins/’ directory.
2. Activate the plugin through the ‘Plugins’ menu in WordPress.
3. Go to Settings and configure the options eg. Copy and paste the Google Adsense code that you want to use.
4. Add the trigger text <!– wp_ad_camp_1 –> to a post or page where u want it to appear.
Usage
There are two ways you can use this plugin:
1. Add the following trigger text to a post or page in HTML view
![]()
2. Call the function from template files:
<?php echo show_ad_camp_1(); ?>
or <?php echo show_ad_camp_2(); ?>
or <?php echo show_ad_camp_3(); ?>
This Plugin in Action
See this plugin in action below or on Antique HQ.
Download
Download the Plugin from here.
Donation Option
Donation option can be found on my projects page.
Change Log
- Version 1.1
- Fixed an issue whereby sometimes Google Adsense code were disappearing from the settings page in some WordPress themes.
Additional Documentation
How to Add Google Adsense to the Sidebar
In order to add Google Adsense on the sidebar using the ‘Simple Adsense Integration’ Plugin you will need to use the following PHP function:
<?php echo show_ad_camp_1(); ?>
If you are calling the function from the theme’s template file (sidebar.php) then you are fine but there is another way to do this using the widgets which could be more practical in some cases.
1. Download and activate the Executable PHP code plugin if you don’t have it already. This plugin lets you call php functions from the widgets (it’s similar to the Text widget but it lets you execute PHP code too).
2. Go to the widgets menu and add a ‘PHP Code’ widget to the sidebar (where you want to display the Google Adsense block). Now add the following line of code and save the settings:
<?php echo show_ad_camp_1(); ?>
This will display an The Google Adesne ad that is saved in the number one textarea of this plugin.
How to Wrap Text Around a Google Adsense Block
To left align the Adsense block and wrap text around it just use the following div for the Adsense unit in HTML view:
<div style=”float: left;”>
Adsense Goes Here
</div>
To right align the Adsense block and wrap text just change “float: left;” to “float: right;”. So for an example, the following will left align the Adsense Unit that is saved in the Ad Campaign 1 box and wrap text around it.
<div style=”float: left;”>
<!- – wp_ad_camp_1 – ->
</div>
If you need help with this plugin or want to suggest an enhancement/feature then please let me know by leaving a comming in the comment area below.
Tags: Google, google adsense, Wordpress, Wordpress Plugin








#1 by Adrian on November 14, 2008 - 1:48 pm
Great plugin thanks
#2 by Rudy on November 18, 2008 - 12:56 pm
How about a plugin for Google Ad Manager? Would be nice to have a plugin that allows you to tag posts so that a corresponding widget to display appropriate Ad Manager ads in the sidebar (or the posts for that matter)
#3 by Ed & Donna on November 25, 2008 - 11:02 pm
Hi,
I have downloaded the adsense plugin and was very excited, but can’t get it to work. I am using WP and when I put the google adsense in the campaign 1 box it doesn’t stay..disappears. I have looked all over for a save button or something but can not find it.
When I put the trigger code in the page it doesn’t get the adsense code because it is no longer in the box!
What can I do?
Thanks sure looks like it would make my life easier…
Captain Ed & Donna
#4 by admin on November 25, 2008 - 11:34 pm
Hi Captain Ed & Donna,
Lets try to get your plugin to work properly. This plugin is used by a lot of people including myself and I haven’t heard any complains yet so I have a feeling that in your case it’s not working for some silly reason. I am going to give you a few pointers to try and hopefully this should fix it.
1. There is no reason to explicitly save your Google Adsense code in the Campaign code text area. All you need to do is copy and paste the Google Adsense code in one of the Ad Campaing code text areas and Hit “Update Options” (This will save the adsense code). The “Update Options” button is located in the lower left hand corner.
2. Now you can use the trigger text e.g. to display that ad in your post or pages. Make sure when u add the trigger text to your post or pages, you do it from the “HTML” view and not from the “Visual” view. You can switch between the “HTML” and “Visual” view by clicking the button on the upper right hand corner of the post or page editing menu.
3. Make sure you copy and paste the Full Google Adsesne ad code from your Google Adsense account into the Ad Campaign code text area and hit “Update options”. Don’t worry if the Ad text doesn’t stay in the text area. It is stored in the variable and should work fine when you use the trigger text.
Let me know how you go. Cheers!
#5 by Captain Ed & Donna on November 26, 2008 - 12:45 pm
Thank you so much for your perfect reply. I have done exactly what you have instructed and it would not work which was why I posted!
After I read the reply I figured I would just try it again and it worked perfect!!!!! The only problem I see now is in the google code, there are two angle brackets in the ad section. I will check out there and get another code.
This worked like a charm and I just LOVE the easy of placing goggle ads.
THANK YOU SO MUCH!
Captain Ed & Donna
#6 by Anonymous on November 27, 2008 - 7:40 pm
will your adsense pluin work for an Adsense Search Bar and an Adsense link unit?
#7 by admin on November 27, 2008 - 7:42 pm
Yes, the Google Adsense Insertion Wordpress Plugin will work fine for Link units and Search bars.
#8 by Joshjava on November 28, 2008 - 5:23 am
Great plugin… very easy to use. Definitely made the use of Google Adsense on my blog easier. Thanks for this Plugin.
#9 by Upendraya on February 8, 2009 - 11:00 am
To start earning money with your blog, initially use Google Adsense but gradually as your traffic increases, keep adding more and more money making programs to your site.
#10 by Google Money on February 27, 2009 - 12:04 am
This is exactly what I was looking for, thanks!
#11 by lucy on February 27, 2009 - 4:15 am
Hello
I am having problems getting this plugin to work!
I copied all the instructions to the T. Copied and pasted in HTML mode, but like the above poster, the text just disappears out of the box! OK, you said not to worry about that – it should still be stored… but, despite putting the trigger text into the post… no adsense shows up at all!
Any suggestions?
Thanks for your time in answering this question.
#12 by admin on February 27, 2009 - 6:26 am
Hello Luci, Just thought I would mention this… don’t forget that sometimes it takes about half an hour (even though it says10 minutes) for your Google Adsense unit to start working after you create it. So if you just created the Adsense unit then you will need to wait a little bit before the ad starts to appear. Also, please make sure you are using the trigger text exactly as it is stated in the Readme.txt file… sometimes its easy to miss a ’space’ or capitalize a letter etc.
#13 by lucy on February 27, 2009 - 9:19 pm
Hi admin,
Thanks for the reply.
Yes, I thought it may take some time, so I left it overnight, but this morning… still no ads!
I copied and pasted (into notepad first just to make sure) exactly the text as it appears and … still no joy!
What else can I try?
#14 by Andy on February 28, 2009 - 10:21 am
Hi,
I am very interested in this plug in. I would like to be able to place a square google ad block between the title of my post and the post body. I am not sure from what I have read if this is possible with this plugin. If so, can you tell me where to place the code. I am new to programming to I need to know exactly what code to add where.
Thank you very much for any help you can provide.
#15 by Ken on February 28, 2009 - 1:35 pm
Where do you find the google adsence code to copy? Sorry, newbie.
#16 by admin on March 1, 2009 - 5:02 am
You will have to sign up for Google Adsense from the following URL and then create an ad to get the Adsense code.
Google Adsense
#17 by admin on March 1, 2009 - 5:09 am
@Andy, yes it is possible to place Google Adsense anywhere on your blog page with this plugin. To place a square ad in between the Post title and the Post body, simply copy the the Adsense code for the square ad to one of the Ad campaign code blocks in the Settings of this plugin then use the corresponding tag in your article. Make sure you put the corresponding tag in HTML view as the first line of your article and that should show the ad between the title and the body.
#18 by Ed Coyne on March 1, 2009 - 8:00 am
I’m trying to use the Text widget to add a Google add to my sidebar. Is that the proper way to do it? It doesn’t seem to work. It is, however, working beautifully in my posts and pages.
This is what I have in my Text widget:
I’ve also tried this:
#19 by Ed Coyne on March 1, 2009 - 8:00 am
Just found out I can’t post my html code. Sorry.
#20 by Ed Coyne on March 1, 2009 - 8:03 am
One more thing…
It DOES matter that the code disappears from the textarea, because if the box is blank for number 1, and you add code for number 2, the ad for number 1 disappears.
#21 by admin on March 1, 2009 - 9:31 am
@Ed, To use the Google Adsense on your sidebar using this plugin you need to use the second method which is call the php function from your sidebar.php file or if you use the Executable PHP Widget plugin then you can call the php function using that plugin.
Regarding the issues… its been a while since I released this plugin and since then WordPress has had a few releases so I will have a look at the plugin code and release an updated version (Its on my list of things to do but the list just keeps growing
.
#22 by admin on March 6, 2009 - 12:11 am
Updated version released with the fix whereby Google Adsense Code was disappearing
#23 by Pat on March 7, 2009 - 1:09 pm
I can’t seem to get this to work. I used and just dropped it into my header file. Any suggestions.
#24 by Pat on March 7, 2009 - 1:09 pm
Never mind. I got it working!
#25 by Gary Smith on March 11, 2009 - 8:26 pm
My ad code is disappearing? Won’t hold it? Ideas? I can’t seem to place code in the side bar? Thanks in advance…!
#26 by admin on March 11, 2009 - 11:23 pm
@Gary, Please use version 1.1 of the WordPress Google Adsense Integration Plugin which has the fix whereby sometimes Google Adsense code were disappearing.
To Place google Adsense in the sidebar… Please read one of the comments above that I posted earlier.
#27 by van on March 13, 2009 - 3:37 am
hello admin
i was first creating a new post on my wp with theme freshnews, but i cannot save it, it just hangs on the browser like reading or loading.
what i did is search for google adsense on wp and landed on this page
so i installed the insertion plugin.
but again, once i tried to update the settings and put the code and hits the update
the browser still does not respond again. it just keeps on reading
is there somthing wrong with my adsense code and the wp cannot save it
hope to hear from you thanks
great plugin if this will work.
#28 by yuyo on March 20, 2009 - 1:20 am
thank you got it working, but how to change the color ?
#29 by admin on March 20, 2009 - 1:30 am
If you are talking about changing the color of the Adsense unit then you will have to do it from your Google Adsense Account. If you have already created the Adsense unit then log into your Adsense account and you will be able to change the color by selecting “Edit Ad Settings” from the “Manage Ads” menu under “Adsense Setup”.
#30 by Chris on March 20, 2009 - 8:34 am
FINALLY an adsense-plugin, that works very well and where I can place the ads whereever I want!
Many, many thanks!
#31 by jen on April 5, 2009 - 7:33 am
First of all I would like to say thank for this plugin. It is great.
I am trying to place ads on side bar, and one with any info?
#32 by admin on April 5, 2009 - 7:40 am
To place ad on the sidebar you can just call the corresponding function for that ad. For example the following line will show the ad that you saved in the first ad campaign field:
< ?php echo show_ad_camp_1(); ?>
You can just call these functions from your templates sidebar.php file or there is a plugin called “Executable PHP Code” that lets you add php widget that you can use to execute any php code. The plugin can be downloaded from the following URL
http://wordpress.org/extend/plugins/php-code-widget/
#33 by sean on April 14, 2009 - 8:48 pm
If I want to put a leaderboard ad in my header, how do I do that? On my site, you can see where it will go in the header.
Thanks!
#34 by admin on April 14, 2009 - 9:43 pm
Copy and Paste the Ad code for the leaderboard ad to one of the ad campaign text area of the Adsense Ad integration plugin then open the header.php file of your theme and use the corresponding function to show the ad
< ?php echo show_ad_camp_1(); ?>
When you ad the above line to your header.php file, it will show the leaderboard ad in your header… you will have to put it in the right div block though so it aligns nicely where you want the ad to appear.
#35 by mark on April 22, 2009 - 5:30 pm
Can I used this plugin to wrap text around an adsense block? If so, how?
Mark
#36 by admin on April 22, 2009 - 7:47 pm
@Mark, Yes u can use this plugin to wrap text around a google Adsense block. I have updated the post with the information you need… please see the “How to Wrap Text Around a Google Adsense Block” section in the post above.
#37 by ROMA Finale 2009 on April 25, 2009 - 10:04 am
Hi.
do your plug in works with wordpress 2.7.1.
Thanks
#38 by admin on April 25, 2009 - 10:46 am
Yes, the Google Adsense Integration plugin works with WordPress 2.7.1
#39 by ROMA Finale 2009 on April 25, 2009 - 12:36 pm
Hi, admin.
I just install and make setting for your plugin.
I tried a lot of Google Adsense’s manager plugins 4 WP but yours is the easyest and customized one.
Next days i will going to add the code in each posts.
If i get some free time i will translate with pleasure your plugin in italian language.
Please show me where insert the italian phareses in php code plugin.
MANY THANKS 4 YOUR PLUGIN
Regards
Leave me a mex in my blog
#40 by Ryan on April 26, 2009 - 4:58 pm
Hi
Thanks for the plugin. I unfortunatly had problems with it aswell. I inserted my ad codes and all worked well until I needed to edit one of the codes, I went to settings to see that all ad codes wernt there and the boxes were empty. I just tried re-inserting the code I wanted to edit and pressed update options to see if that worked. I ended up wiping the other two ad blocks away although the edited code worked. Seems abit daft that if you want to edit one ad code you have to insert all three again????
My suggestion for future releases would be :-
1. Code stays visible for each ad slot and can be edited
2. Able to add more ad slots so you can use diferent ad networks or for affiliate links.
Thanks again for the plugin
ooops just fixed the disapearing code by updating to newest version, should of read propely….
#41 by Barbera Orlinsky on April 27, 2009 - 2:28 pm
Hi, I cant understand how to add your site in my rss reader. Can you Help me, please