The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 05:31:18 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Need help pulling keywords please...  (Read 4234 times)
greenway
Rookie
**
Offline Offline

Posts: 12


View Profile
« on: April 29, 2007, 01:53:14 PM »

I am trying to pull the keywords used by search engines to find my webpages.

This is the php I am using:

Code:
function getkeywords($thereferrer){
$searchengines=Array("search.yahoo p", "google q", "altavista q", "alltheweb q", "search.msn q");
for($i=0;$i<count($searchengines);$i++){
$currsearch=split(" ", $searchengines[$i]);
if(strpos($thereferrer, $currsearch[0])!=false){
$searchqueries=split("&", split("?", $thereferrer[1]));
break;
}
 }
if($searchqueries){
for($i=0;$i<count($searchqueries);$i++){
if($searchqueries[$i][0]==$currsearch[1]){
$thekeywords=join(", ", split(" ", urldecode($searchqueries[$i][1])));
break;
}
 }
  }
return $thekeywords;
}





if($referrerpage!="") $keywords=getkeywords($referrerpage);
else $keywords="Not Available";

I am inserting a .js file in the footer to pull the info and keeping the log results in a text file.

The .js file is working fine and I am getting results but not any keywords used ?
« Last Edit: April 29, 2007, 01:55:28 PM by greenway » Logged

No links in signatures please
greenway
Rookie
**
Offline Offline

Posts: 12


View Profile
« Reply #1 on: April 29, 2007, 02:15:33 PM »

Sorry mods just noticed this is in the code repository section.

PLEASE MOVE POST FOR ME  Embarrassed
Logged

No links in signatures please
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #2 on: April 30, 2007, 02:34:18 AM »

The .js file is working fine and I am getting results but not any keywords used ?

I wonder what results you are getting?

I can't help you with php, but what i would do with perl is *first* just save the
referer string to a text file.

Then I could practice parsing the keywords offline and when I get that going, I could add that code.

that's just me,
Bompa
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #3 on: April 30, 2007, 05:15:57 AM »

I agree with Bomps' approach.

On a PHP level I would also be inclined to print_r($searchqueries) just before the;
if($searchqueries){
line and see what you've got.

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
greenway
Rookie
**
Offline Offline

Posts: 12


View Profile
« Reply #4 on: April 30, 2007, 10:49:39 AM »

I agree with Bomps' approach.

On a PHP level I would also be inclined to print_r($searchqueries) just before the;
if($searchqueries){
line and see what you've got.

Cheers,
td

A blank page  ROFLMAO
Logged

No links in signatures please
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #5 on: April 30, 2007, 05:41:58 PM »

that means your $searchqueries variable is not being set.

Change;
$currsearch=split(" ", $searchengines[$i]);

to;
$currsearch=split(" ", $searchengines[$i]);
print_r( $currsearch );

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!