I would simply like to get referring page keywords from:
HTTP_REFERER

ie. If referrer is:
http://search.yahoo.com/bin/search?p=search+keywords
OR
http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=other+keywords

How do I get just the "search keywords" OR "other keywords" parts?
I have the referring pages stored in a 'stats' MySQL database and would like to extract the keywords from the URLs stored there, but I am willing to add a 'keywords' row and start entering just the keywords in it if I have to.

    Nevermind...

    I figured it out this way:

    //Referring page possible keyword values
    $possiblekeywords = ARRAY(
    "ask",
    "keyword",
    "Keywords",
    "p",
    "q",
    "qry",
    "qt",
    "qu",
    "query",
    "s",
    "search",
    "string",
    "su",
    "text"
    );

    $totalsearchterms = querydatabase("SELECT Referrer, COUNT(Referrer) as todsearchterms FROM stats WHERE Referrer LIKE '%search%' GROUP BY Referrer ORDER BY todsearchterms DESC, Referrer LIMIT $limit;");

    while ($myrow = mysql_fetch_array($totalsearchterms)) {
    $searchterm = ARRAY($myrow[Referrer]);
    foreach ($searchterm AS $searchterms) {
    $searchwords = parse_url($searchterms);
    $queryvalue = $searchwords["query"];
    foreach ($possiblekeywords AS $keywords) {
    if (preg_match("/\b$keywords\b/i", $queryvalue)) {
    parse_str($queryvalue, $query);
    $queriedwords = $query[$keywords];
    echo "<b>$queriedwords</b>";
    }
    }
    }
    echo "&nbsp;$myrow[todsearchterms]<br>";
    }

      I think you would like to add SZUKAJ to your array 🙂 It's in Polish :>

        Write a Reply...