For those of you out there with web pages containing a lot of JavaScript you can do a simple operation that will not only help your search engine ranking, but allow you to easily customize your Adsense or other JavaScript ads. This simple operation is known as a "server-side include."
First, let's talk about how server-side includes can optimize your web pages. Search engines, like Google, take into consideration the HTML to script ratio of your pages when ranking them in their listings. So if your page has as much JavaScript as HTML you are more likely to be ranked under a page that contains no JavaScript.
Now, most of you know that JavaScript is what most advertisements are written in. Google's Adsense is a primary example. Let's take a look at an ad:
<script type="text/javascript">
<! -
google_ad_client = "pub-111111111111111";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_text = "000000";
google_color_url = "000000";
// - >
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Google allows you to have up to three of these ads on each page. That can be a lot of JavaScript if your page doesn't have that much content. Also, if you're using feeds to automatically populate your pages with content, then your templates (web pages) are even more laden with script.
We want Google to look kindly on our page and rank it as high as possible. So what can you do? Well, you could get rid of all your ads and feeds… Not going to happen? Hmm… If only there were some way to make the search engines think that we didn't have any JavaScript on our page but yet still keep the JavaScript… I have good news for you; there is an easy way you can do this. You guessed it. We can do it with the wonderful server-side include operation! How exciting!
If you do not know, a sever side include is when a server automatically plugs in the code (JavaScript, HTML, whatever it may be) into the HTML document whenever the client (a person at a computer browsing the web) accesses the page. Thus, when various search engine spider programs riffle through your HTML document they do not see any JavaScript!
So where does this JavaScript hide? In a separate document of course. I have a separate document for each type of Google add. I keep them in a separate folder on my server for organization.
With a server-side include you can create HTML documents and add one line of code to them to pull all the code stored in these files and place it in the HTML document whenever a page is requested by a client. However, search engine spider programs used to rank pages only see the raw HTML of the template; they cannot see what will be included after our server performs the server-side include.
To do a server-side include you must use a server-side scripting language like PHP, Coldfusion, or ASP.net. The best language to use is PHP (PHP is a recursive acronym that stands for hypertext pre processor). Coldfusion costs a ton of money and ASP.net only works well with Microsoft's SQL server. There are several sites on the web that offer free PHP tutorials. You can also find ColdFusion tutorials, ASP.net tutorials as well. For our needs we only need to use one small line of PHP code. Feel free to Google around for more tutorials, you have my permission.
Before we go further you should note that your web host needs to have PHP capabilities enabled. iPower, the host I am currently using, allows me to use PHP. If you still need to choose a web hosting company I have an excellent review of the top three web hosting companies (these three all have PHP enabled on their servers) on my website. Click HERE to read it. Alright, I'm assuming you have chosen a web host. If you had chosen one a while ago and you'd like to change after reading my article you might be able. Most companies offer a 30 or 60 day money back guarantee.
Here are the steps to performing server-side includes:
Step One
You need to place your JavaScript code in a separate document. Just cut and paste it into a new text pad document and save it as some relevant name. BUT, we must modify the extension from .txt to .php. For those of you who have Windows you may not be able to modify the extension. You can fix this by opening up any folder selecting "tools" from the menu and then selecting "folder options." Next select the "view" tab and then look for the check box with the words "Hide known extension types" and uncheck it. Hit apply and then close the window. I hate when windows hides the extension types because you cannot modify them easily. After this is done simply rename the file with a .php at the end.
Step Two
Where you cut the JavaScript or other code out you'll need to place an include statement that will tell the sever to insert all the code in the php file you just made in step one. Here is what the code looks like in PHP:
This code will tell the server to open the ad_format.php file and copy everything in it into our html document. When you use this code, simply replace ad_format.php with your own php file name.
Whenever I have a skyscraper Adsense ad, I put a php statement that looks like this:
<? php include("skyscraper.php"); ?>
I keep the skyscraper code saved in a separate document. This saves me a ton of time and effort because all I put in is one line of code for each ad. I have a mesothelioma page with two skyscraper adsense ads that put in by a server side include. Mesothelioma is a great adsense subject as it pays you upwards of $50 per click. Click here to see my page. (You can copy my article and use it on your own site, just give me a link back!)
Step Three
Every page that uses PHP you'll need to modify its extension from .html or .htm to .php. So all of your html pages need to be modified to have a .php extension. And if you're using ASP or Coldfusion you'll need to change them as well to .cfm or .asp. I changed my articles.html to articles.php.
Step Four
Every Google Adsense ad has the same formatting code. That is, the code that determines the color of the ad elements or the type of ad is the same for each ad. So, we can take advantage of this using PHP. What if you could change one line of code and modify every Adsense ad in your site? You could experiment with all kinds of colors and images to see which combination yielded the most clicks.
To do this is easy. Simply include a PHP include in the file where you stored your Adsense code. You are going to cut out the formatting code and store it in a separate php file. After this is done It will look something like this:
The ad_format.php file will then contain all the following code you just cut out:
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_text = "000000";
google_color_url = "000000";
When you want to modify the ad, simply alter the code in your ad_format.php file, upload it to your server and voilĂ ; every ad in your site changes. If you don't know how to modify colors in HTML I suggest you go through a few HTML tutorials. Don't worry, it is incredibly easy. So go ahead, experiment and play different tricks with the PHP includes to further simplify the process of customizing your ads.