Improvements for Stattraq plugin.

April 29, 2007 by aaron

Ever since I originally started using Stattraq a few things bothered me about the way it worked. Here are the fixes to a few of them.

Include pages with posts in your stats.

  1. Open stattraq.php
  2. Find:

    global $doing_rss, $p

    Replace With:

    global $doing_rss, $p, $page_id, $pagename,

  3. Find:

    if (($p != '')){
        $p = intval($p);
        $article_id = $p;

    Replace with:

    if (($p != '')){
        $p = intval($p);
        $article_id = $p;
    }elseif (($page_id != '')){
        $page_id = intval($page_id);
        $article_id = $page_id;
    }elseif (($pagename != '')){
     $reqpage = get_page_by_path($pagename);
        if ( !empty($reqpage) )
            $article_id = $reqpage->ID;

To add a list of all Pages that link to your site grouped by Website (excluding Google):

Open “wp-stattraq/reporter/summary.php”


<?php echo PrintTimestamp();?>
            <div id="queryTerms">

Before Add:

<table id="referrersTable">
    foreach($results as $row){
        preg_match(&#039;/(http.*?\:\/\/.*?)(\/.*)/&#039;, htmlentities($row->ref), $matches);
        $ref_array[$matches[1]][] = $matches[2];

    while( list($site, $pages) = @each($ref_array) ){
        if(strpos($site,&#039;google&#039;) ==false && $site != &#039;&#039;){?>

            <tr class="<?php echo ($i % 2 == 0 ? &#039;even&#039; : &#039;odd&#039; );?>"><td><?php echo ++$i;?></td>
            <a href="<?php echo $site;?>"><?php echo substr($site,0,50);?></a></td>
            <td class="right">

        <?php foreach($pages as $page){?>

            <a href="<?php echo $site.$page;?>"><?php echo substr($page,0,50);?></a><br/>


<?php   }
Categorized as:
comments powered by Disqus