Thursday, September 04, 2003

What we need from stats = benefits & why the AU home page under achieves...

Enter ClickTracks. ClickTracks processes your logs, intelligently, so that you
don't have to study raw text files or decipher fancy bar graphs. ClickTracks
features your Web site in an internal browser and superimposes detailed
information about the activity on the pages you're looking at. The stats include
information like: how many visitors saw each page, how much time people spend on
each page, how they get to the page, and most important, what page they visit
next. Each "link" on your page is shown in a special way within the ClickTracks
viewer so that you can see what percentage of visitors clicked on each link. We
used it to analyze JimWorld and immediately saw that users were bypassing the
links on our home page that we wanted them to follow (the articles), and were
heading down to other links. Because of ClickTracks, I realized that our home
page was really just a bunch of links into the main parts of JimWorld, and was
not set up to make it easy for visitors to find the specific parts of JimWorld
that they were looking for. So, I divided the home page into sections that are
targeted at specific types of visitors (Designers, SEOs, Programmers,
Marketers), and provided each of them with the links that were relevant to them.
Guess what? Our traffic levels haven't changed, but I've found that visitors
to our home page are now seeing an average of 5 to10 additional pages when they
visit JimWorld.

Code for setting up Google API to check ranking.

One of the things essential to any SEO, and really, to anyone who operates a Web
site, is to know where they rank at Google for a given search term or phrase.
Using the GoogleAPI, we can very easily find out where a site ranks, without
having to visit Google.com and going dizzy reading the results. The source code
for "test.php" follows, and is commented so that you can follow the logic.
Happy position checking!



// test.php
// A simple way to check positions for a given domain, for given keywords
// at Google.com. Uses the googleAPI to make things easier
// This application is free for non-commercial use under the GPL
// Please keep this copyright and header intact.
// (c) 2003 John Cokos, JimWorld.com


// This pulls in the SOAP_Google Class file //
require_once 'google.php';

// For Clarity, let's use real variable names //
$terms = $_POST[keyword];
$domain = $_POST[domain];

// Draw a very simple form //
echo "




Keyword / Phrase:


Domain to Check:







";

// If the form has been filled out .... get to work.
if ( $terms && $domain ) {

// Create a new oject using the SOAP_Google Class. All you need to
// Do is give it your googleAPI license key

$google = new SOAP_Google('YOUR-GOOGLE-LICENSE-KEY');

// Use that Google object to run a search. In this example, we simply
// pass along the search terms, and ask for the first 10 results. You
// can also specify a higher number of results, where to start from,
// turn on safe searching, etc. For our purposes, we just want the
// basic top 10 results.
$result = $google->search(
array(
'query' => $term,
'maxResults' => 10
)
);

// Now, the results of searching Google are in an object called "$result"
// This is actually an array of objects, that we can iterate through
// to do what we want

// Make sure that we actually got results //
if (false !== $result) {

// Tell the user what we have done //
echo "Checked: $domain for $term ....

";
// What we're going to be doing is reporting the position of our domain

// For the given search term, so first, we make sure that we're starting
// at "0", so that the counter works right.
$position = 0;

// Now, Iterate through the result set. Each "$listing" is a PHP Object
// that contains the data for the current search result in the list
foreach ( $result->resultElements as $listing ) {

// Increase the position Counter
$position++;

// If the domain we asked to check ($domain) is contained within the
// URL of the current search result, we have a match, so let's display
// it on screen just like a Google result. Note that for the purposes
// of what we're doing, we really don't need to display the listing, just
// report the position, but I wanted you to see how to manipulate the
// results.

// Note that this will show you every match of the domain that it finds
// so that you can see if you appear multiple times.

if ( eregi( $domain, $url ) ) {

// Create some logical variable names //
$title = $listing->title;
$snippet = $listing->snippet;
$description = $listing->summary;
$url = $listing->URL;

// Dump it out just like a listing //
echo "


Position: $position


$title

$snippet

Description:
$description

$url




";
$found = 1;
}
}

// If we did not appear in the top 10, report it.
if ( ! $found ) { echo "Not found in first 10 positions"; }
}

// This will return a simple error message if we got nothing back from google //
else {
echo 'Query failed.';
}
}

// This will show if the form was not filled out //
else { echo "Please fill in the form above completely"; }

?>

Resources:

Google API Sign up: http://www.google.com/apis/
PHP PEAR::SOAP Extension: http://pear.php.net/package-info.php?pacid=87
SOAP_Google Class for PHP: http://www.sebastian-bergmann.de/?page=google
Perl SOAP Library: http://search.cpan.org/author/KULCHENKO/SOAP-Lite-0.55/

Google
Creative Commons Licence
This work is licensed under a Creative Commons License.