Recent Topics

1 Jun 10, 2005 13:49    

Hi,
I posted a topic similar to this before, but never got an answer. Does anyone know how / where to fix the code to handle extracting keywords from search engine referrals? In my stats I get quite a few listings under the Referring Searches that say:

[not a query - no params!]
[no query string found]

Mostly they show up for Dogpile, Google Groups, and LinksManager, & BlogHop. I know it has something to do with find the "q=" or "&search=" etc in the referring url and extracting the following word. The problem is Dogpile uses a non standard "http://dogpile.com/search/web/keyword" as a referring URL. There is no ? or q= to find. Bloghop I think uses "http://www.bloghop.com/?word=keyword" or something similar.

Just want to find out where to alter to code to account for these and extract keywords if possible.

2 Jan 01, 2006 18:45

This is similar to a problem that has been bothering me, except it is the a9.com search engine.

So, I did something about it. First, I added 'a9.com' to conf/_stats.php.

Then I made this change to b2evocore/_functions_hitlogs.php

--- b2evocore\_functions_hitlogs.php.orig	Sun Jan 01 12:40:14 2006
+++ b2evocore\_functions_hitlogs.php		Sun Jan 01 12:37:34 2006
@@ -468,6 +468,23 @@
 	$ref = $row_stats['referingURL'];
 	if( ($pos_question = strpos( $ref, '?' )) == false )
 	{
+		if(stristr($ref, 'a9.com/'))
+		{
+			$q = urldecode(substr($ref, strrpos( $ref, '/')+1));
+			if( strpos( $q, 'Ã' ) !== false )
+			{	// Probability that the string is UTF-8 encoded is very high, that'll do for now...
+				//echo "[UTF-8 decoding]";
+				$q = utf8_decode( $q );
+			}
+			$qwords = explode( ' ', $q );
+			foreach( $qwords as $qw )
+			{	
+				if( strlen( $qw ) > 30 ) $qw = substr( $qw, 0, 30 )."...";	// word too long, crop it
+				$kwout .= $qw.' ';
+			}
+			echo htmlentities($kwout);
+			return;
+		}
 		echo '[', T_('not a query - no params!'), ']';
 		return;
 	}
@@ -492,6 +509,24 @@
 			echo htmlentities($kwout);
 			return;
 		}
+	}
+	if(stristr($ref, 'a9.com/'))
+	{
+		$pos_eslash = strrpos($ref, '/');
+		$q = urldecode(substr($ref, $pos_eslash+1, $pos_question-$pos_eslash-1));
+		if( strpos( $q, 'Ã' ) !== false )
+		{	// Probability that the string is UTF-8 encoded is very high, that'll do for now...
+			//echo "[UTF-8 decoding]";
+			$q = utf8_decode( $q );
+		}
+		$qwords = explode( ' ', $q );
+		foreach( $qwords as $qw )
+		{	
+			if( strlen( $qw ) > 30 ) $qw = substr( $qw, 0, 30 )."...";	// word too long, crop it
+			$kwout .= $qw.' ';
+		}
+		echo htmlentities($kwout);
+		return;
 	}
 	echo '[', T_('no query string found'), ']';
 }

The Dreamer

3 Jan 07, 2006 04:37

Here's what I added for 'dogpile.com':

       }
+      else if(stristr($ref, 'dogpile.com/'))
+      {
+          $q = urldecode(substr($ref, strpos( $ref, 'search/web/')+11));
+          $pos_slash = strpos($q, '/');
+          $q = urldecode(substr($q, 0, $pos_slash));
+          if( strpos( $q, 'Ã' ) !== false )
+          {   // Probability that the string is UTF-8 encoded is very high, that'll do for now...
+              //echo "[UTF-8 decoding]";
+              $q = utf8_decode( $q );
+          }
+          $qwords = explode( ' ', $q );
+          foreach( $qwords as $qw )
+          {	
+              if( strlen( $qw ) > 30 ) $qw = substr( $qw, 0, 30 )."...";	// word too long, crop it
+              $kwout .= $qw.' ';
+          }
+          echo htmlentities($kwout);
+          return;
+      }
       echo '[', T_('not a query - no params!'), ']';

The Dreamer


Form is loading...