Title: ShortStat problems.. (PHP Script)
Last modified: August 18, 2016

---

# ShortStat problems.. (PHP Script)

 *  [matthewrobertson](https://wordpress.org/support/users/matthewrobertson/)
 * (@matthewrobertson)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/shortstat-problems-php-script/)
 * I downloaded and installed Shaun Inman’s Shortstat ([found here](http://shauninman.com/mentary/past/nofollow_the_leader.php)).
 * Everything worked perfectly. The `trackme.php` page (which tests if the code 
   works) worked perfectly.
 * The problem was implementing.
 * The author said to implement
    `<?php @include_once($_SERVER["DOCUMENT_ROOT"]."/
   shortstat/inc.stats.php"); ?>` into any pages wishing to be tracked.
 * Okay. So I put this in the `header.php` via WP 1.5’s Theme Editor. Logic said
   that putting the code in `header.php` would make the code go on all pages.
 * The problem was the code didn’t work.
    If you visited the test page, it recorded
   the visit. If you visited a normal PHP page (without WP), it recorded the vist.
   But any pages built via WP did _not_ record the visit.
 * The code was inserted correctly. I put an `echo` in the code, and it echoed back
   on all pages. _If it echoes correctly, shouldn’t it track correctly?_
 * It doesn’t.
 * **Does WP allow scripts to run (with MySQL functions and what have you) in ‘themes’?
   Because it’s got something to do with WP.**
 * ~~~
 * Try it yourself (prove me wrong please)
 * 1. Visit my ShortStat site (**You will have to type the address in manually**:`
   www.bugger.3rror.com/shortstat/`)
 * 2. [Visit trackme.php](http://www.bugger.3rror.com/shortstat/_trackme.php) (its
   a simple php page with the tracking code on it.)
 * 3. Go back to my ShortStat site (`www.bugger.3rror.com/shortstat/`). It should
   have recorded your visit.
 * 4. Now go to a WP page, say [the home page](http://www.bugger.3rror.com/) or 
   a perma link. This has the same code as the trackme page.
 * 5. Go back to my ShortStat page (`www.bugger.3rror.com/shortstat/`). Did it record
   your visit? When I do it, it doesn’t.
 * **What’s wrong?**

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-161993)
 * Don’t add it to the header. Add it to the footer instead. Place it in footer.
   php right after the sentence or last word and before `<div id="footer">` closes.
 * Though, I wouldn’t recommend Shortstat as it hasn’t improved much for quite a
   while (a few bug fixes and tiny features here-and-there). IMO, BAStats (a WordPress
   plugin) looks more promising.
 * [http://www.asymptomatic.net/archives/2005/02/14/1307/ba-stats/](http://www.asymptomatic.net/archives/2005/02/14/1307/ba-stats/)
   
   Download: [http://asymptomatic.net/wp-hacks](http://asymptomatic.net/wp-hacks)
 *  Thread Starter [matthewrobertson](https://wordpress.org/support/users/matthewrobertson/)
 * (@matthewrobertson)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-161995)
 * Thanks.
 * Would you mind explaining why I should put it in the footer (for future references)?
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-161998)
 * Well, the header controls how your posts are displayed and how the rest of the
   theme is accessed. So, the going opinion is to not mess with the header unless
   you’re really confident in what you’re doing, and you could have easily put the
   ShortStat code in a position that would have prevented it from working. The footer,
   on the other hand, is expendable (easy to fix) and is displayed on every page(
   in most themes). Similarly, all active WP plugins “hook” into either the footer
   or the sidebar.
 *  Thread Starter [matthewrobertson](https://wordpress.org/support/users/matthewrobertson/)
 * (@matthewrobertson)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162011)
 * Sorry, but it doesn’t seem to be working.
 * I’ve placed it all over the `footer.php` but no luck.
 * I don’t understand why. It calls the script and everything. It just doesn’t “
   record the visit.”
 * **What can I do?**
 * _On your suggestion to BAstats, I just want a simple one for now. Shaun Inman’s
   was promising and looks slick. I still would like to use it._
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162019)
 * Well, I can tell you that it’s not a problem with WordPress. I have both PHP 
   code (with MySQL functions) and javascript code in my footer. You’ll have to 
   talk to the developer some more.
 *  [serif](https://wordpress.org/support/users/serif/)
 * (@serif)
 * [21 years ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162675)
 * I am having the same problem as Mathew. Finally got Shortstat working (after 
   fixing some IIS issues), and the _trackme.php does it’s job perfectly. Have tried
   adding the Shortstat code into my WP site though and no results come through.
   Have tried adding it into the header, footer, index.jsp etc. but no luck. Anyone
   else out there had this problem and fixed it?
 *  [jehiah](https://wordpress.org/support/users/jehiah/)
 * (@jehiah)
 * [21 years ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162692)
 * Two comments.
 * In your configuration.php you need to turn logging on.
 * change the ‘false’ to ‘true’ in the last line
 * `$shortstat = true;`
 * Second, it doesn’t matter if you put the include in your header or footer. It
   would matter if the logging required a separate page request from the client (
   like including an image in the page), but it doesn’t. Shortstat is entierly server
   side, and will not display to your page, so no need to wrap it in a div block
   and put at the end of the page.
 * As for ShortStats not being improved, I have a sweet plugin that i’ve added. 
   Just drop a few files into your shortstats folder and check it out. (end shameless
   plug)
 * [Pathstats – ShortStat plugin](http://jehiah.com/archive/pathstats)
 *  [jennmiller](https://wordpress.org/support/users/jennmiller/)
 * (@jennmiller)
 * [21 years ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162693)
 * jehiah, that is indeed a SWEET addition.
 *  [serif](https://wordpress.org/support/users/serif/)
 * (@serif)
 * [21 years ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162694)
 * Matthew – is your site hosted on an IIS server? If so there are a few workarounds
   that need to be made for shortstat to work nicely. I’ve just managed to get it
   going (finally!). For anyone else interested, it turns out that $_SERVER[‘DOCUMENT_ROOT’]
   and $_SERVER[‘REQUEST_URI’] used in Shortstat aren’t supported on IIS. To get
   it working I had to change the call to the include file to be:
 * `if(!isset($_SERVER['DOCUMENT_ROOT'])) {`
    ` $_SERVER['DOCUMENT_ROOT'] = substr(
   $_SERVER['PATH_TRANSLATED'],0,strlen($_SERVER['SCRIPT_NAME']) * - 1);` ` }`
 * And in the Shortstat include file itself I needed to change:
 * `$res = $_SERVER['REQUEST_URI'];`
    to be `$res = $_SERVER['SCRIPT_NAME'];`
 * Hope this is useful for someone. It drove me nuts for a while.
 *  [ralph](https://wordpress.org/support/users/ralph/)
 * (@ralph)
 * [21 years ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162707)
 * [@serif](https://wordpress.org/support/users/serif/): Firstly, the script works–
   it just doesn’t work with WP.
    If you have the same problem, and you solved it
   above, could you explain in detail how you did, please?
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [21 years ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162708)
 * Ralph, I’m using ShortStat with no problems. I put the ShortStat call at the 
   top of the main index.php (in the wordpress directory).
 *  [serif](https://wordpress.org/support/users/serif/)
 * (@serif)
 * [21 years ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162710)
 * Hi Ralph. I did the same as macmanx and put the include right at the top of my
   index.php file. This seemed to work, but for some reason if I tried putting it
   in the header or footer it didn’t. No idea why. The only changes I made to the
   shortsat code were the ones I mentioned above, and one other [concerning page references](http://design.sneak.co.nz/?p=40),
   but these were due to the server my site is on.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘ShortStat problems.. (PHP Script)’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 6 participants
 * Last reply from: [serif](https://wordpress.org/support/users/serif/)
 * Last activity: [21 years ago](https://wordpress.org/support/topic/shortstat-problems-php-script/#post-162710)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
