PHP Classes

Search Keywords: Get the search words that lead an user to a page

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-16 (2 months ago) RSS 2.0 feedStarStarStar 46%Total: 3,114 This week: 1All time: 1,162 This week: 560Up
Version License PHP version Categories
searchkeys 3.0.0GNU General Publi...8.0.0HTTP, Searching
Description 

Author

This class can be used to retrieve the search words entered by an user in a search engine site that lead the user to the current page.

The class can parse the HTTP_REFERER CGI variable if present. Then it can detect which search engine site lead the user to the current page, and extract the search words.

Currently the following engines are supported:

- Google
- Yahoo/AllTheWeb
- Bing
- Ask/AskJeeves
- Baidu

Picture of Eric Sizemore
  Performance   Level  
Name: Eric Sizemore is available for providing paid consulting. Contact Eric Sizemore .
Classes: 14 packages by
Country: United States United States
Age: 36
All time rank: 15119 in United States United States
Week rank: 14 Up2 in United States United States Up
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Example

<?php

/**
 * @author Eric Sizemore <admin@secondversion.com>
 * @package Search Keywords
 * @version 3.0.0
 * @copyright 2006 - 2024 Eric Sizemore
 * @license GNU GPL v3
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * Honestly, there is not much to using this class. It is very simple and does
 * not take much to get going. You really only need to do the following:
 */

// First include the class file.
require_once('./Keywords.php');

// Next, instantiate the object using it's "getInstance()" function
$keys = \Esi\Search\Keywords::getInstance();

// Everything else is pretty much handled for you automatically.
// Calling 'getKeys()' will automatically parse the referrer for you.
$keys = $keys->getKeys();

/*
 * The 'getKeys()' call will return an array with the following structure:
 *
 * array(3) {
 * ['referer'] => 'referrer url',
 * ['keywords'] => 'keyword',
 * ['engine'] => 'search engine'
 * }
 *
 * For example:
 *
 * array(3) {
 * ['referer']=> string(160) "https://search.yahoo.com/search;_ylc=X3oDMTFiN25laTRvBF9TAzIwMjM1MzgwNzUEaXRjAzEEc2VjA3NyY2hfcWEEc2xrA3NyY2h3ZWI-?p=test&fr=yfp-t&fp=1&toggle=1&cop=mss&ei=UTF-8"
 * ['keywords']=> string(4) "test"
 * ['engine']=> string(5) "yahoo"
 * }
 */
if (count($keys)) {
    echo
"Referring URL: $keys[referer]<br />Keywords: $keys[keywords]<br />Search Engine: $keys[engine]";
}

/*
 * The above will output something similar to:
 *
 * Referring URL: https://search.yahoo.com/search;_ylc=X3oDMTFiN25laTRvBF9TAzIwMjM1MzgwNzUEaXRjAzEEc2VjA3NyY2hfcWEEc2xrA3NyY2h3ZWI-?p=test&fr=yfp-t&fp=1&toggle=1&cop=mss&ei=UTF-8
 * Keywords: test
 * Search Engine: Yahoo
 */

// And honestly, that's really all there is to it.


Screenshots  
  • snap.gif
  Files folder image Files  
File Role Description
Plain text file Keywords.php Class The main class file
Accessible without login Plain text file example.php Example Example usage
Accessible without login Plain text file LICENSE.md Lic. License

 Version Control Unique User Downloads Download Rankings  
 0%
Total:3,114
This week:1
All time:1,162
This week:560Up
User Ratings User Comments (1)
 All time
Utility:65%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:62%StarStarStarStar
Tests:-
Videos:-
Overall:46%StarStarStar
Rank:3175