Adding Google Adsense and Analytics
This morning I spent some time adding Google Adsense adds and Google Analytics to my web site. This was mostly just an experiment to see how the two services work together, and to find out a little about where web traffic comes from and where it goes.
Since my web site has been sadly pathetic for so long there are very few links to it from other sites, so it’s almost like starting up a virgin web site (even though jeff.com has been around since about 1992). Prior to today it was getting between 80 and 200 unique visits per day, mostly just to the home page, with just a handful of people drilling down into the rest of the site. Now that I’m adding a little more content it will be interesting to see what happens over time.
Adding Google Adsense ads was pretty easy. Signing up for an Adsense account takes a couple days, I guess Google reviews new applications before issuing the accounts. But once that’s done getting the actual ads to work is easy. The first thing to do is follow Google’s instructions for setting up your Adsense account, including setting up a few ad formats (called “units”) and copying the code they provide for each.
I use Wordpress now to publish this site so I went about adding the ads in two different ways. First, I wanted to put a “tower” ad box in the right sidebar of my customized Wordpress theme. But, I didn’t want any ads to appear on my home page, or on the photo albums and other stuff that I had just copied from my old static web site. Second, I wanted to sprinkle ads into the content of my blog postings and such, since that’s probably where any interesting (if you can call it that
content will be. So I had to modify my site in two ways.
Putting a Google Adsense Tower in the Sidebar
The Wordpress sidebar in my theme (and probably most themes will be set up similarly) is defined in the “sidebar.php” file in my theme directory. It really just boils down to an unordered-list of items, so adding to the bottom of the list was easy, I just had to add the code:
<?php /* JEFF: add google ad tower */ ?><?php /* If this isn't a static page */ if ( !is_page() ) { ?><li><script type="text/javascript"><!--google_ad_client = "pub-123456789012345";/* 160x600, created 7/19/08 */google_ad_slot = "12345678";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></li><?php /* end of is_page */ } ?>
All the javascript code is just copied from Google’s Adsense page after creating the ad unit. The only important thing here is the PHP block which encloses the javascript inside a conditional statement “if ( !is_page() )”. In Wordpress, is_page() will return true if the current page is one of the site’s static pages (ie, not a blog page or posting or one of the pages automatically-generated to contain blog entries in the archives, categories, or other lists). Since I didn’t want ads on my home page and other static pages I exclude those from getting the ad display code. There is also a function is_home() which is useful, but a little misleading, in that it returns true if the current page is what Wordpress uses for the most-recent blog postings. In my case this is not my home page, I use a static page for my home page, so here is_home() returns true on my “Ramblings” page, which confused me a little until I figured out what it was doing.
After adding this to the sidebar.php file the ads started showing up, and I went back to the Google site to set the background color and border color so it matched my sidebar colors from the main stylesheet.
Sprinkling Google Adsense ads in the Blog Content
A while back when setting up Wordpress (and one of the reasons I decided to use it) I discovered a Wordpress plugin “All in One Adsense and YPN” which will automatically insert either Google or Yahoo ads into the site. I had installed the plugin already (which just entails unpacking the zip file into the wordpress plugins directory) so all I had to do was activate it and enter my Google ID number. I fiddled a bit with the settings and eventually settled on just a couple small ad boxes, which it inserts randomly in the content. Sometimes it ends up picking funky places to put them but it seems to work pretty well most of the time.
Like with the Tower ad I adjusted the colors to match my theme. Remember also that Google limits the number of ad displays you can have on one page to three, so including my tower ad I had to set the number of ads per page to two.
Adding Google Analytics
Google Analytics is a really cool tool which shows an amazing amount of data, graphed in many different ways making it easy to learn a lot about web site traffic. I’ve used it for corporate web sites that I manage but never one that I had total control over, so adding it to my own site gives me a chance to be able to fiddle with the site to see how changes can effect traffic.
Adding Google Analytics is even easier than adding the ads. Like the ads it just involves adding a snippet of javascript which Google provides, to each page on your site. My theme uses the same footer for every page, so I just added the javascript code to the footer.php file right before the </body> tag and that’s it, now Google is collecting data on my site’s activity.
Results
Now I guess I just have to wait and see what happens. I don’t really expect to make any money from these ads but I will be very interested to see what sort of view and click-through rates these things get. It seems like the click-throughs must be pretty darn low, I don’t think I’ve ever clicked one of those ads on someone’s site, but we’ll see. The first ads that showed up were for some guy “Jeff Buckley”, who must be a musician or something, but I’ve never heard of him, who the hell is this guy?
Jeff W:
Jeff Buckley im pretty sure is a dead musician…
Anyway it’d be interesting to see what percentage of your traffic is comprised of other “Jeffs” just cruising the internet. You may be able to see that I came from Dan.com because my roommate wanted to see what that was all about. I still don’t know what Dan.com is, just weird crap, take a look.
2 August 2008, 10:15 amJeff D:
I think Jeff W is right. I come here once a year or so hoping you would give it up some time. Guess not.
Good luck with your website.
Jeff D
10 August 2008, 11:16 amJeff O:
Yeah, I check this site once every few years to see if its gone. I wonder what percentage of traffic is indeed not referred from anywhere.
Best of luck and congrats on the sweet domain.
24 September 2008, 2:39 pmJeff D (a different one):
yep, always come to see if somehow, some way, i can get this domain. pipe dream, of course. i have jeffdewaters.com but, its down atm. i dont arrive from anyway, my name is just jeff. ha.
26 October 2008, 6:59 pm