PHP Classes

CReferrer: Extract search engine keywords from referrer URL

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 56%Total: 2,954 All time: 1,263 This week: 673Up
Version License Categories
creferrer 1.0.0GNU General Publi...HTTP, Text processing
Description 

Author

Most browsers usually send the URL of a page the user accessed before and clicked on a link or submited a form that lead to the current page. That information is usually passed to PHP scripts in HTTP_REFERER environment variable.

This class is meant to parse the HTTP referer URL of the page that lead the user to the current page and determine if it is a known search engine.

In the case that a known search engine is recognized, the class can extract the search keywords that the user entered in the search site.

The class comes with a data file that is used to described 24 known search engines. You may edit this file to add more entries to let the class recognize more search sites from the referer URL.

Innovation Award
PHP Programming Innovation award nominee
March 2004
Number 6
Where are my site visitors coming and why, are frequent questions asked by many site owners. One way to track that information is using the HTTP referer headers that tell the URL of the page that the user visited before the current page.

The search engine sites are one common source of new visitors. Usually the user searches for something and the search engine site presents a list of pages where what is searched may be found. The search keywords are part of the URL of the search engine result pages. When the use clicks on a result link and accesses the listed site, usually the browser passes to that site the URL of the search engine results page in the HTTP referer header.

What this class does is to parse the HTTP referer header and try to match it against the URL pattern of several well known search engine sites.

This definitely helps answering Web site owner questions about where did my site visitors come from and what where they searching for that lead them to my site.

Manuel Lemos
Picture of Filippo Toso
Name: Filippo Toso <contact>
Classes: 20 packages by
Country: Italy Italy
Age: 45
All time rank: 151 in Italy Italy
Week rank: 180 Down7 in Italy Italy Down
Innovation award
Innovation award
Nominee: 5x

  Files folder image Files (3)  
File Role Description
Plain text file creferrer.class.php Class CReferrer class
Accessible without login Plain text file engines.ini Data Search engines settings
Accessible without login Plain text file test_referrer.php Example Test script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,954
This week:0
All time:1,263
This week:673Up
 User Ratings  
 
 All time
Utility:83%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:77%StarStarStarStar
Tests:-
Videos:-
Overall:56%StarStarStar
Rank:1742