Google SERP checker using Google AJAX Search API‏

A warning before you proceed: Google hate you when you are using its API for automated position tracking

So.. Google provide us Google AJAX Search API which we can use to fetch Google search result. The bad news is that it only provide maximum 64 search result.
More info about this API, read here:

We’ll use this API to track our domain position on Google SERP for certain keywords, it’s useful to track your SEO progress.

Full main function source code here:


//helper function -- file_get_contents using curl
function file_get_contents_curl($url, $referer='', $ua='')
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    if ($referer!='') {
        curl_setopt($ch, CURLOPT_REFERER, $referer);

    if ($ua!='') {
		curl_setopt($ch, CURLOPT_USERAGENT, $ua);

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_close ($ch);

    return $data;

//this is the main function
function g_serp($keyword, $url, $lang='en')

	for ($i = 0; $i < 64; $i+=8)

		$referer='http://localhost/'; //change this into your real domain
		$rawdata=file_get_contents_curl($g_url.'&start='.$start, $referer, $_SERVER['HTTP_USER_AGENT']);
		$decoded=json_decode($rawdata, TRUE); //decode as assoc array

		if (is_array($decoded['responseData']['results']))
			$pos = $start;
			foreach ($decoded['responseData']['results'] as $result) {
				if (substr_count(strtolower ($result['url']), $url))

					return $res;


The main function is g_serp() and I create one function helper file_get_contents_curl(). The main function use json_decode(), so, your PHP version must be at minimum 5.2. The function designed to stop at first domain match. You can modified yourself so the function continue to search until 64 results (maybe you want to check whether your domain shown more than one on Google SERP).

Parameters explanation

  • $keyword --> the keyword that you want to check. Example: 'how to upload mp3 to youtube'
  • $url --> your domain name (without 'http://'). Example:
  • $lang --> target language, different language target might cause different position result. Example (choose one): en, de, fr, id    

Usage example

require_once "gserp.php";

$keyword='how to upload mp3 to youtube';

print_r(g_serp($keyword, $url, $lang));

Example output

    [0] => Array
            [position] => 7
    [1] => Array
            [title] => MP32U.NET - Create simple video from your MP3 and a JPG image
    [2] => Array
            [url] =>

So, as you can see, at this time of writing, rank #7 on Google English ( on keyword: how to upload mp3 to Youtube

Fully working demo can be tested here:

Leave a comment ?


  1. Hi ! Big thanks for this 🙂
    I’m from France and have got a little problem. There is $lan fr but when i search some keyword without “lyon” for exemple, hav got no results. Even with a &pwd=0 in my serp url, i’m in 5 positions but still no results ! I’m puzzle 🙂

    Thanks again

  2. Is there no other function to specified to place the research in a specific serp ?
    Thanks for the answer

  3. mas, sampeyan karo indovision opo aora ?, nek aora jarene gambare ilang nek udan ?

  4. pak, kalau musim kemarau kayak sekarang ini apa Aora stabil terus atau ada gangguan juga ? LOST signal…

    • Di sini stabil2 saja tuh. Klo ndak ada hujan deres yg dtg tiba2, smua baik2 saja. Klo cmn hujan biasa(yg ndak disrtai petir), sinyal jg masih oke.

  5. mas, baru januari kemaren di daftarin domainnya…sekarang udah PR 3, gimana mas tips& triknya biar bisa demikian…thanks

    • entahlah,
      ndak bisa SEO aku.. tulisan yg berkualitas saja mungkin.
      ini saja sdh jarang nulis2 lagi.. penginnya sih aktif lg di dunia per-online-an.. tp sibuk mlulu.

      • kerja offline/konvensional juga ya mas…ta kira cuman murni online dari situs2 video

        • Malah ndak aktif lg di online, plg cmn ngecek sesekali doang. Kerja offline jd programmer freelance banyak menyita waktu.

  6. nice share bro…
    btw ada demo website SERP Script yg udah jadi belum?
    tx ya

  7. Thanks for the info. Does this method still work? I’m trying to get some working code for my SEO students so they don’t have to pay for the expensive tools.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>