Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum
Register Blogs Search Today's Posts Mark Forums Read

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-27-2009, 08:14 PM
Newbie
 
Join Date: Oct 2009
Location: Bristol, UK
Posts: 23
adzeds is an unknown quantity at this point
PHP Web Analytics

I am trying to write a PHP script that collects website data.

I am trying to write a function that checks if the referrer was a search engine, if it is it gets the search engine domain and the keywords used.

Any tips?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-27-2009, 08:27 PM
Jordan's Avatar
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 24,556
Jordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to all
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Re: PHP Web Analytics

You'll need to use $_SERVER['HTTP_REFERER'] to determine that information. There is also a PHP class you can use or take ideas from located here: CReferrer (referer) - PHP Classes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-29-2009, 08:16 PM
Newbie
 
Join Date: Oct 2009
Location: Bristol, UK
Posts: 23
adzeds is an unknown quantity at this point
Re: PHP Web Analytics

Here is some of my code, does not seem to work though!

Any ideas?

PHP Code:
function searchEngine()

{
    
$refer parse_url($_SERVER['HTTP_REFERER']);
    
$host $refer['host'];
    
    if(
strstr($host,'google'))
    {
        
$searchengine "yes";
        
$sedomain "Google";
        return 
$searchengine;
    }
    elseif(
strstr($host,'yahoo'))
    {
        
$searchengine "yes";
        
$sedomain "Yahoo";
        return 
$sedomain;
    }
    elseif(
strstr($host,'msn'))
    {
        
$searchengine "yes";
        
$sedomain "MSN";
        return 
$sedomain;
    }
}

function 
getKeywords()
{
    
$refer parse_url($_SERVER['HTTP_REFERER']);
    
$host $refer['host'];
    
$refer $refer['query'];
    
    if(
strstr($host,'google'))
    {
        
//do google stuff
        
$match preg_match('/&q=([a-zA-Z0-9+-]+)/',$refer$output);
        
$querystring $output[0];
        
$querystring str_replace('&q=','',$querystring);
        
$keywords explode('+',$querystring);
        return 
$keywords;
    }
    elseif(
strstr($host,'yahoo'))
    {
        
//do yahoo stuff
        
$match preg_match('/p=([a-zA-Z0-9+-]+)/',$refer$output);
        
$querystring $output[0];
        
$querystring str_replace('p=','',$querystring);
        
$keywords explode('+',$querystring);
        return 
$keywords;
        
    }
    elseif(
strstr($host,'msn'))
    {
        
//do msn stuff
        
$match preg_match('/q=([a-zA-Z0-9+-]+)/',$refer$output);
        
$querystring $output[0];
        
$querystring str_replace('q=','',$querystring);
        
$keywords explode('+',$querystring);
        return 
$keywords;
    }
    else
    {
        
//else, who cares
        
return false;
    }

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-31-2009, 12:46 PM
John's Avatar
Co-Administrator
 
Join Date: Jul 2006
Age: 21
Posts: 5,835
John is just really niceJohn is just really niceJohn is just really niceJohn is just really niceJohn is just really nice
Send a message via AIM to John Send a message via MSN to John
Re: PHP Web Analytics

What's not working?
__________________

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-02-2009, 03:29 AM
Newbie
 
Join Date: Oct 2009
Location: Bristol, UK
Posts: 23
adzeds is an unknown quantity at this point
Re: PHP Web Analytics

The:
$keywords & $sedomain
variables seem to be returned blank!

How do I return more that one variable from a function?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-04-2009, 11:35 AM
Newbie
 
Join Date: Oct 2009
Location: Bristol, UK
Posts: 23
adzeds is an unknown quantity at this point
Re: PHP Web Analytics

Anyone got any advice on this!

Really want to create a good script to collect web stats.

Anyone know any existing scripts that i could customize?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Web Analytics Script adzeds PHP Forum 4 10-25-2009 07:42 AM
PHP 5 and OOP Jordan PHP Tutorials 11 09-22-2008 02:58 AM
PHP 4 end of life announcement Jordan News 4 08-30-2007 10:55 AM


All times are GMT -5. The time now is 09:27 AM.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0