Avoid Google keyword detection picking up Firefox ‘aq=’

For those of you who are monitoring or stripping keywords from referrer strings from Google you may be seeking out the query string parameter ‘q=’.
Beware that a simple string match on ‘q=’ could lead you to match on the additional Firefox parameter ‘aq=’. This appears in a Google referrer string if the search terms were originally searched for from the Firefox searchbar.
The aq=t parameter was added by Mozilla in 2006 at the request of Google.

Make sure that any string matching you’re doing is looking for a preceeding ampersand (&) or question mark (?) so that you match the ‘q=’ parameter correctly.

2 thoughts on “Avoid Google keyword detection picking up Firefox ‘aq=’”

  1. Good point there Jon. I’ve been using the following snippet to detect these things…


    if ($_SERVER['HTTP_REFERER']){
    $refer = $_SERVER['HTTP_REFERER'];
    $referrer_url = $refer;
    if (strstr($referrer_url, "google")) {
    $sitefrom = "Google";
    $ptn = '![?&]q=([^&.]*)!';
    } else if (strstr($referrer_url, "yahoo")) {
    $sitefrom = "Yahoo";
    $ptn = '![?&]p=([^&.]*)!';
    } else if (strstr($referrer_url, "msn")) {
    $sitefrom = "MSN";
    $ptn = '![?&]q=([^&.]*)!';
    if (preg_match($ptn, $referrer_url, $matches)) {
    $qstring = urldecode($matches[1]);
    logaction("arrived from " . $sitefrom .", searched for '" . $qstring . "'");

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.