Title: Twatch include in WP
Last modified: August 18, 2016

---

# Twatch include in WP

 *  [boing](https://wordpress.org/support/users/boing/)
 * (@boing)
 * [20 years, 8 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/)
 * Hy there again… one more problem. I’m trying to include an external php file 
   to all wp pages. It’s an statistic script – TraceWatch – i say it’s the best 
   free one.
 * My problem sounds like this: i’m inserting the include command:
 * <?php @include_once $GLOBALS[‘HTTP_SERVER_VARS’][‘DOCUMENT_ROOT’].’/twatch_include/
   logger.php’; ?>
 * … in all my template files, but nothing is changing in the statistics. If i’m
   using an external page from wp script – works fine.
 * Is there an another way i can include this code to all my WP pages… ?
 * Tnq…

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/twatch-include-in-wp/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/twatch-include-in-wp/page/2/?output_format=md)

 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273649)
 * I know as much php as you can write on the back of a stamp with a marker pen,
   but I’d guess that the Globals is killing it ?
    Why not just use an absolute 
   URL ?
 *  [prjctfish](https://wordpress.org/support/users/prjctfish/)
 * (@prjctfish)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273761)
 * I am also interested in using twatch on my WP blog; I use it on my site [http://www.simonmetz.com](http://www.simonmetz.com)
   and love it. So one could one change the variable to
 * <?php @include_once
    [http://www.sitename.com/twatch](http://www.sitename.com/twatch)?
   > and the relative position.
 * Thanks,
 * –S
 *  [prjctfish](https://wordpress.org/support/users/prjctfish/)
 * (@prjctfish)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273766)
 * I got it to work-
 * placed this code in the footer.php of the theme dir
    <!– WORKS–> <?php @include_once
   $GLOBALS[‘HTTP_SERVER_VARS’][‘DOCUMENT_ROOT’].’/twatch_include/logger.php’; ?
   >
 * </body>
    </html>
 *  [owl](https://wordpress.org/support/users/owl/)
 * (@owl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273788)
 * I tried the way you did it but no luck here. If I put the code into footer.php
   the page doesn’t fully load, sometimes it reloads. And the footer text doesn’t
   load at all.
 *  [owl](https://wordpress.org/support/users/owl/)
 * (@owl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273789)
 * Most likely it’s about that $GLOBALS thing. I don’t know php but isn’t that thing
   called before? or turned off? or whatever?
 * PLEASE HELP!
 *  [owl](https://wordpress.org/support/users/owl/)
 * (@owl)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273790)
 * Thanks to Terry from Superaff.com I solved the problem. See last comments in 
   [this blog entry](http://superaff.com/archives/2005/02/20/free-web-stats/).
 * So if you want TraceWatch to work with your WordPress blog then put ther proper
   twatch php include in index.php which is in your blog’s root directory (*not*
   the one in theme dir).
 *  [davfink10](https://wordpress.org/support/users/davfink10/)
 * (@davfink10)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273808)
 * Ok – I’m just not getting this. I’ve tried placing the code in the <WP directory
   >/index.php file on the first line. No luck. I tried placing it everywhere – 
   in the theme/header.php file in the theme/footer.php file. What am I missing?
   Can you post exactly what code you are using successfully and what file to place
   it in. I’ve tried the javascript version as well and didn’t have any luck with
   that either. THe interesting thing is – I made a dummy blank php page, put the
   reference code in there and then browsed to it – that worked fine. I just can’t
   figure out how to include it in my WP files. Please help. Thank you.
 *  [niziol](https://wordpress.org/support/users/niziol/)
 * (@niziol)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273809)
 * I had been having problems with getting twatch to work in WP as well, the only
   way I’ve managed to make it work is putting the code in the WP index.php and 
   the blog-header.php. I know, very odd, it has to be in both files or it doesn’t
   work at all.
 * Any ideas as to what would make it only work with having the code in both files?
   I’m using the exact same twatch code as I’ve used on everything else, so I know
   it works, it’s just this quirky thing with WP.
 * Cheers,
    Michael.
 *  [davfink10](https://wordpress.org/support/users/davfink10/)
 * (@davfink10)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273810)
 * Still having problems!!! Can anyone help? This is where I’m placing the code.
   Am I placing it in the right place? Am I using the right include code? Is anyone
   aware of plugins, settings or anything that may be conflicting? Please let me
   know what works for you.
 * **WP index file:** _‘WP dir’_/index.php
    `<?php /* Twatch */ @include_once $GLOBALS['
   HTTP_SERVER_VARS']['DOCUMENT_ROOT'].'/twatch_include/logger.php'; /* Short and
   sweet */ define('WP_USE_THEMES', true); require('./wp-blog-header.php'); ?>
 * **Header file:** _‘WP dir’_/wp-content/themes/_‘theme dir’_/header.php
    `... 
   <body> <?php /* Twatch */ @include_once $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT'].'/
   twatch_include/logger.php'; ?> ...
 *  [niziol](https://wordpress.org/support/users/niziol/)
 * (@niziol)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273811)
 * I wasn’t clear in my post, I put the code in the WP-dir/index.php and the WP-
   dir/wp-blog-header.php files and that’s the only way it works for me, is if the
   code is in both.
 * The include codes that you have looks fine to me. If anyone figures this having
   to put it in 2 files thing out, please let me know.
 * Cheers,
    Michael
 *  [davfink10](https://wordpress.org/support/users/davfink10/)
 * (@davfink10)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273812)
 * Michael,
 * Thank you for your help. I tried placing it in both files – still with no luck.
   I’m at my wits end on this one – I’m not sure what else to try. I’m running WP
   2.0.1 and TraceWatch V0.234.
 * Is there any way you can paste your code placement that you have setup – I just
   want to make sure I’m not doing something wrong. It would be greatly appreciated.
   Thanks again.
 *  [niziol](https://wordpress.org/support/users/niziol/)
 * (@niziol)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273813)
 * I’m using the exact same versions of both as you are. I have this after the WordPress
   stuff in the root index.php file:
 * `<?php
    $GLOBALS['adl_alt_docroot']=$GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT'].'/
   tw'; $GLOBALS['adl_count_params']=true; @include_once $GLOBALS['adl_alt_docroot'].'/
   twatch_include/logger.php'; ?>
 * And I have the exact same code in the wp-blog-header.php file. My tracewatch 
   is in a tw sub-directory.
 * For the life of me, I can’t figure out why I have to have it in both files. I’ve
   tried everything I could imagine and this is the only way it works! I’m going
   to give it some more thought this weekend and try to figure it out. If I manage
   to get it working properly, I’ll try and do up a plugin for it. Let me know if
   you make any progress on your end!
 * Cheers,
    Michael.
 *  [davfink10](https://wordpress.org/support/users/davfink10/)
 * (@davfink10)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273814)
 * Ok Michael,
 * Thank you … I think I’m getting closer. 😐 I haven’t gotten it working on my 
   WP directory yet but I think I know what the culprit is. I have my WP directory
   set up as a subdomain eg. df.davefink.com – I believe this to be the problem.
   I tried playing around with the code on a blank (non-WP) page. When I browse 
   to it as df.davefink.com/test.php – it doesn’t track – however when I go to davefink.
   com/df/test.php – it does.
 * I’m guessing that it has something to do with the “Local root folder” setting.
   I’ve been trying to setup the “absolute file system path” setting using this 
   [http://www.tracewatch.com/doc/code.php](http://www.tracewatch.com/doc/code.php)
   but I can’t get it to work. Not even when I browse to davefink.com/df/test.php.
   I’m wondering if I have my path wrong, should I use an absolute path [http://davefink.com/stats](http://davefink.com/stats)
   or the server path /home/[user]/public_html/stats. I haven’t had luck either 
   way and I couldn’t find any further documentation.
 * My last resort is to set up WP in the root public_html folder – I’ve just been
   trying to avoid this b/c I like to keep my directory clean and I have other sites.
   Anyway I’m givin this one my all before I do that. If you have any suggestions
   or ideas let me know. Thanks again for all your help. I appreciate it.
 * Dave
 *  [davfink10](https://wordpress.org/support/users/davfink10/)
 * (@davfink10)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273815)
 * OK OK – Progress is good:
 * I got the absolute path working – now it tracks both df.davefink.com and davefink.
   com/df – woo whoo!!! It turns out that code generator strips the first “/” when
   creating the path – not good. So instad of /home/public… it was home/public… 
   This is why I couldn’t get it to work. Alas … one problem down.
 * Now back to WP. Ugh!!! So I have the correct include code, but I still can’t 
   get it to work – in fact when I placed it in the index.php file and the wp-blog-
   header.php file – it broke my site – noting would show up. 🙁 Damn it – I thought
   I had it, ah well. I’m still chuggin’ – got any suggestions let me know.
    Thanks,
   Dave
 *  [davfink10](https://wordpress.org/support/users/davfink10/)
 * (@davfink10)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/#post-273816)
 * OK – well I give up for now. I just can’t seem to get the PHP version working.
   It doesnt matter where I place it – everytime it destroys my page from fully 
   loading. I think it has something to do with the $GLOBALS call – but I really
   have no idea. 🙁
 * Sadly … I’m just going to use the JS version and place it in my theme/footer.
   php file – that seems to work.
 * If anyone finds a solution working with WP 2.01 – please post. I know I can’t
   be the onlyone.
 * Thanks,
    Dave

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/twatch-include-in-wp/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/twatch-include-in-wp/page/2/?output_format=md)

The topic ‘Twatch include in WP’ is closed to new replies.

## Tags

 * [external](https://wordpress.org/support/topic-tag/external/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 19 replies
 * 8 participants
 * Last reply from: [menguzar](https://wordpress.org/support/users/menguzar/)
 * Last activity: [19 years, 6 months ago](https://wordpress.org/support/topic/twatch-include-in-wp/page/2/#post-273865)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
