I just launched my first website I fully wrote myself in php/mysql - www.TomPaineToday.com. After testing it on my own computer for a while, I decided I might as well launch it and see what problems I run into.

The first issue I came across was that my link redirect counter loves counting the Google Bot. Now, I am sure many people have had this idea in the past and will tell me why I should not do it, but what problems will I cause if I treat Google Bot "clicks" differently then human clicks by filtering IPs?

After I find out that this will blacklist me from Google or whatever other devastating problems it will cause, is there an open list of IP addresses that I should disregard for future click counting?

Thanks

tp

PS
Sorry if this is the wrong forum, but since I am doing this in php, thought this was more appropriate than seo/marketing forums.

Member Avatar for LastMitch

@paine_today

Can you post the code? At least.

Yes, it's the wrong forum, it should be in the Internet Marketing section but if you have the php code then there's no problem

Thanks, will move it.

UPDATE: I'm new here... I am not seeing an option to remove a post? :-/

You could always use a robots.txt file to disallow Google bots indexing the click counter links.

Here is the code I have been using. As mentioned above, I was considereing adding different clauses for known bots.

    $user_ip = $_SERVER['REMOTE_ADDR'];
    $time_now = time('%s');
    $tobe_redirect = $_GET['url'];
    $article_id = md5($tobe_redirect);
    $query = "INSERT INTO `stats` ( `article_id` , `user_ip` , `time`) ";
    $query .= "VALUES ('{$article_id}','{$user_ip}', {$time_now})";
    if (mysql_query($query,$connection)) {
    // Success!
    }
    else {
        // Display error message
    }

    $redirect = "Location: " . $_GET['url'];
    header($redirect);

@blocblue

Thanks for the suggestion. I will look more into that. Other than allowing or disallowing certain pages from being index, I am not familiar with the capabilities of robot.txt files.

Member Avatar for LastMitch

@paine_today

Thanks for posting the code.

I apologize I'm not familiar with SEO. So far from PHP, You created a DB to fetch those info in order to block Google Bot:

$query = "INSERT INTO stats ( article_id , user_ip , time)";

I think what blocblue mention about robots.txt is more appropriate:

http://support.google.com/webmasters/bin/answer.py?hl=en&answer=156449

I feel blocblue more experience in SEO than I.

@LastMitch

The bit of code you reposted is basically the query that adds an entry to the db when a link is accessed. I was considering adding clauses to handle bots differently.

Looks as though that link has my answer. I take it Google would look down on handling them in a different manner then the rest of the world is treated.

Member Avatar for LastMitch

@paine_today

It's good that you post the code now because someone beside me can help you with this.

I'm not familiar with SEO at all and I don't even know how to write code regarding about SEO.

I was considering adding clauses to handle bots differently.

So that will help more

Thanks for your help LastMitch!

You can use get_browser() function or $_SERVER['HTTP_USER_AGENT'] to read the user agent of the clients and if there is a match with Google bots you will not run the query, something like:

<?php

$browser = $_SERVER['HTTP_USER_AGENT'];

if(!preg_match('/Google[bot]/i',$browser))
{
    # insert query here
}
else
{
    echo 'bot';
}

?>

the else statement is optional. Here's the list of Google bots user-agents: https://developers.google.com/webmasters/control-crawl-index/docs/crawlers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.