Showing posts with label google. Show all posts
Showing posts with label google. Show all posts

Saturday, October 1, 2011

Document/Attachment Reader - Google


Hi,

In this post I will discuss about document reader I had to use in one of my project. The files that we upload, their contents can be easily viewed using this reader. This is a product of Google. This is how it looks like:


Code:

Implementation of the Google document reader is extremely simple. Here is what you need to acheive it.

Tuesday, April 12, 2011

Google Page Rank Calculation


Hi,
Page rank is an algorithm used by Google search engine, initially formulated by Sergery Grin and Larry Page. It is a algorithm which gives a rating to a particular web page. All the big companies are spending many dollars to increase their page rank. It may look daunting, but the page rank algorithm is in fact quit elegant and simple as follows:

PR(A) = (1-d) + d{ PR(T1)/C(T1)  + ...............+ PR(TN)/C(TN) }

PR(A) = page rank of page A.
PR(T1) = page rank of page T1 which links to page A.
C(T1) = number of outgoing links from page T1.
d = damping factor 0 < d < 1

Explanation:

Saturday, April 9, 2011

Optimizing your page to come up in Google search

Hi,

This is a continuation of my previous post. In this I will be highlighting few generic rules making your web page appreciable to search engine. The search is basically performed on keywords. Such as "PHP Books", where PHP and Books are two different keyword. You need to architect your website in such a way that these two keywords in your page makes sense to Google.

Here are 10 ways how and where you will use those keywords and optimizing your web page:

1. In META keywords. Not necessary but a good practice. Keep them short and max till 255 characters

2. In META description. Keep the keywords towards the left, but forming a complete meaningful sentence.

3. In the page title. In extreme left, but not the first word.

4. In a H3 tag or higher. Use only once H1 tag in a page and multiple H2, H3 etc. as needed

5. In page URL. Do not duplicate the keywords in URL. Try to use .html or .htm in URL's to be on the safe side. You can use .htacces to convert your .php or .aspx files look like .html/.htm files.

Thursday, April 7, 2011

SEO Tip


Hi,

For a change I won't be submitting any source code in this post :), rather discuss a very favorite topic of mine, SEO. Search engine optimization is a very vast and a mystical thing. No one can teach you SEO, you need to find your own strategies. But there are always few basic basics, which I will be highlighting in this POST.
(All the points are in reference to Google search engine)

First why we need SEO?
Search engine optimization simply means building a website which can be found by various search engine, such that your website name shows up when a search is performed. If your website shows up in search results then your chances of bringing viewers to your site increases. Its a way to increase traffic to your site. And as we all know traffic is all we need for a websites success ;)

How do we put our website in search engines database?
Well this might not be such a difficult question to answer. Few basic steps you may take are:

1. Submit your URL to Google through http://www.google.co.in/addurl.html
2. Sitemaps:

Create a webmaster account for your website. For this you need to have a Gmail account. Login to that account and go to https://www.google.com/webmasters/tools/ and add your website. But the job is not done yet, now you need to create sitemap xml files for the various pages in your website, upload it to your server and submit the URL for that file in the webmaster tools. After you have done that, Google will start scanning those URL's and index them.

Check out my earlier post for creating sitemaps or you can also refer to sitemaps.org for the format of the sitemap XML's.
You can also create the sitemaps for your website, using www.xml-sitemaps.com

Google adsense working logic (advertisement impression tracking) - PHP


Hi,

In this post I will demonstrate how you can advertise on other website and keep track how many times the advertisement has been loaded in that website. This is again an example from GD library. For this I need a database to store the various images for advertisement. The database schema is as follows:

(Click here to download the entire source code with the full database)

1. Table for storing the various advertisement details

CREATE TABLE IF NOT EXISTS `advertisements` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`img` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

2. Table for keeping track of impressions
CREATE TABLE IF NOT EXISTS `adsense_track` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`ip` varchar(30) DEFAULT NULL,
`dt` datetime DEFAULT NULL,
`imgid` int(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

For you to advertise your image you need to supply a simple <img> to the external webpage or blog. In this it will look like:

<img src="http://localhost/php/adsense/advertisement.php?ad_id=1">

Now the source of the image is a PHP file with a parameter ad_id. Now in advertisement.php I have the following:

$ad_details=@mysql_fetch_array(mysql_query("select * from advertisements where id=".$_GET['ad_id']));
if(!empty($ad_details)){

 mysql_query("insert into adsense_track set ip='".$_SERVER['REMOTE_ADDR']."', dt='".date("Y-m-d H:i:s",time())."', imgid='".$_GET['ad_id']."'");
 $im=imagecreatefromjpeg($ad_details['img']);
 header("content-type: image/jpeg");
 imagejpeg($im,null,100);
}else{
 
 $im=imagecreatefromjpeg("noimage.jpg");
 header("content-type: image/jpeg");
 imagejpeg($im,null,100);
}


Explanation:

Saturday, March 5, 2011

Google Sitemaps - Indexing URL's in Google

Hi,

Google sitemaps are an excellent way to let google know about the various webpages of your website. By default the google will crawl your website once in a while, but if you create sitemaps and submit them to google, then the indexing gets speed up and also a lot of pages might get indexed in google search engine.

By the term sitemap, I am not referring to the general websites sitemap.html which tell you what are the links and what are the sub links inside the website. Google sitemaps is like a special xml file with predefined tags, each of which has an distinctive meaning. Here is a sample content of a sitemap.xml file:


<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.90">
  <url>
    <loc>http://www.url.com/</loc>
    <lastmod>2010-01-27T23:55:42+01:00</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>http://www.url.com/page1.html</loc>
    <lastmod>2010-01-26T17:24:27+01:00</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>http://www.url.com/page2.html</loc>
    <lastmod>2010-01-26T17:24:27+01:00</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.5</priority>
  </url>
</urlset>

The given tags are predefined. <loc> contains the URL you want to index, <lastmod> is when the content was last modified, <changefreq> is how often its content gets changed and <priority> is how important is the file; where 1 is most important and .1 is least.