BlogEngine is a great tool for writing Blogs, and I use it to run this site. One of the great features about BlogEngine is that you can write your own extensions for just about anything you can think of. One of the things I wanted to add to my blog was a way to easily integrate AdSense ads. AdSense is a program provided by Google to generate a bit of income from your blog in the form of advertisements. If you haven't created an AdSense account you can do so at Google AdSense.
After signing up for Google AdSense you will need to create 1 or more Ad Units. Each of these will give you set of code to insert into your website. The code will look similar to the following based on your selections:
<script type="text/javascript"><!--
google_ad_client = "ca-pub-xxxxxxxxxxxxxxxx";
/* AdUnit Name */
google_ad_slot = "xxxxxxxxxx";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
I wanted my Google Ads to show up in 2 places: my sidebar on the right (which is a collection of widgets) and I wanted them to show up in the middle of my longer blog posts where the right side bar would no longer be in view. To do this I needed to create 2 extensions to Blog Engine: a widget and an extension. Here's how they work. More...
Tags: BlogEngine, AdSense, Extension, Widget