View Full Version : AXS Visitor Tracking PHP Module
GCT13
12-04-2003, 01:30 PM
The AXS visitor tracking software has been highly recommended by Chris and others on this forum. It comes with a default javascript module code you place on each page of your site.
Below you will find Chris' PHP module code for AXS. Among its advantages over the javascript is the ability to track search engine spiders as they crawl your site. I find this to be a huge benefit. Note that you do loose the ability to not log your visits using this technique. Chris agreed it could be posted in the forum so here it is... enjoy:
if ($_COOKIE['axs_no_log'] != "1") {
$AXSLogFile = '/full/path/to/log.txt';
$AXSTimeOffsetInHours = +1;
$AXSdomain = 'http://www.yourdomain.com';
$AXSuri = $_SERVER['REQUEST_URI'];
$AXSrad = $_SERVER['REMOTE_ADDR'];
$AXSREMOTE_HOST = @getHostByAddr($AXSrad);
$AXSFrom = $_SERVER['HTTP_REFERER'];
$AXSTo = $AXSdomain.$AXSuri;
$AXSHTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
$AXSunixtime = time() + (3600*$AXSTimeOffsetInHours);
$AXSsecond = date("s", ($AXSunixtime))+0;
$AXSminute = date("i", ($AXSunixtime))+0;
$AXShour = date("G", ($AXSunixtime))+0;
$AXSday = date("j", ($AXSunixtime))+0;
$AXSmonth = date("n", ($AXSunixtime))-1;
$AXSyear = date("y", ($AXSunixtime))+100;
$AXSwday = date("w", ($AXSunixtime))+0;
$AXSyday = date("z", ($AXSunixtime))+0;
$AXSlogline =
"|$AXSREMOTE_HOST|$AXSrad|$AXSFrom|$AXSTo|$AXSHTTP_ USER_AGENT|$AXSsecond|$AXSminute|$AXShour|$AXSday| $AXSmonth|$AXSyear|$AXSwday|$AXSyday|\n";
$AXSfile = fopen("$AXSLogFile", "a");
flock($AXSfile, 2);
fwrite($AXSfile, "$AXSlogline");
flock($AXSfile, 3);
fclose($AXSfile);
}
*** Be sure to make the $AXSlogline = "...."; one line, and no space between the quote and the '|', I don't know why vb is doing that.
Reference:
http://www.websitepublisher.net/forums/showthread.php?s=&threadid=392
http://www.xav.com/scripts/axs/
chromate
12-04-2003, 04:43 PM
Use this to prevent logging yourself...
if ($_COOKIE['axs_no_log'] != "1") {
$file = fopen("$LogFile", "a");
flock($file, 2);
fwrite($file, "$logline");
flock($file, 3);
fclose($file);
}
GCT13
12-04-2003, 04:59 PM
Nice one chromate. Would wrapping the whole module in the if statement save server resources?
chromate
12-05-2003, 03:33 AM
Yep. It was just easier to paste that :) Really you should have the whole thing as a function and then use the if statement to call the function if the cookie is not set to 1. Like:
if ($_COOKIE['axs_no_log'] != "1") logVisit();
where logVisit() is the function containing the logging code.
GCT13
12-05-2003, 07:59 AM
Even better.
:cool:
s2kinteg916
12-11-2003, 08:31 PM
so what do u actually do with this ? lol im a bit confused i manage to install axs and im using the javascript
im looking at the stats page and does hits refer to pageviews ?
There were 9 total hits analyzed. Of these, 9 were relevant, and they resulted in 1 lines in the table. No string matching was done against the access log. The log was not filtered by date.
GCT13
12-11-2003, 09:02 PM
Yes, pageviews (and hits from crawlers if you use the PHP module).
http://www.websitepublisher.net/forums/showthread.php?s=&threadid=392
s2kinteg916
12-13-2003, 10:57 AM
well right now i have awstats installed as well... what benefit would i get from installing the php module ? In awstats it tells me how many hits i get from spiders...
Im also looking at my stats for axs and i click on the checkbox
Hits by Day of the Week
it shows Friday 80.08% 1692
so does that mean 1692 pageviews ? without counting any googlebot spiders ? or does that count hits from bots as well...
sorry im a bit confused...
GCT13
12-13-2003, 11:26 AM
You'll be able to log crawlers if you use the php module, that is its main benefit.
With AXS you can get more precision of search engine referrarals info compared to awstats. You can see exactly what search terms where used in what search engine to get to whatever page on your site. In awstats, that info is not as precise, the search engine chart is separated from the keyword chart so you don't know which terms were used with what engine.
Awstats does show crawler hits, but without listing the actual pages hit. In axs you can see which pages were hit when, by what crawler. Right now I'm watching Googlebot index one of my sites, it's kinda fun because I've never seen that before.
it shows Friday 80.08% 1692This is pageviews. If you were using the php module it would also include crawler hits.
s2kinteg916
12-13-2003, 11:39 AM
so with the module installed will it show pageviews and crawler hits seperately ? or all together ?
also how do i implement this ? i see the code there but i dont know what to do with it lol
chromate
12-13-2003, 12:44 PM
With the PHP mod installed it AXS will show the total number of page views. This will include "views" from GoogleBot etc.
As far as how to install it... You know the javascript code that comes with AXS that you put at the top of each of the pages you want to monitor? Just replace that javascript with the PHP code.
GCT13
12-13-2003, 12:53 PM
Originally posted by s2kinteg916
so with the module installed will it show pageviews and crawler hits seperately ? or all together ?In the "Web Browser Type and Version" chart it will display crawlers separately. In the "Day of Year", "Day of Week" charts it will add the hits together and show them all together.
Originally posted by s2kinteg916
also how do i implement this ? i see the code there but i dont know what to do with it lol Go to the first post of this thread and copy that script into its own php file: aws.php. Make sure to read the instructions in that post.
Next, replace the javascript with the php module by including it in each page:
include("/your/path/to/file/axs.php")
Hmmm.... I've just tried this but I get a parse error saying that it's expecting ']" somewhere along the top line of the code you posted.
Anyone know whats wrong?
Thanks,
Mike
GCT13
01-31-2004, 07:39 AM
What line do you get the error?
Did you see the note about the line that starts-
"$AXSlogline = ..." That line should be contained on one line.
Hi all,
I've been using the AX logging package for years, and really like what it does.
But I'd like to be able to use the PHP module. I tried installing this on an Invision Power Board site of mine and it seems to cause a bunch of gobbeldygoop to appear. Somehow the include is messing up javascript or something (that I think causes a popup to jump if you've got a private message, but I'm not entirely sure)
When I include the standard javascript code, it works fine, but when I do the include statement
include("/home/mydomainname/htdocs/axs.php")
it causes a bunch of code to appear at the top of the page.
Anyone have an idea what I could do to make it work?
Thanks in advance,
Juli
Oops, my fault. When adding that to the page, I accidentally stripped out a </script> tag. Fixed that, and now what I get is the include in text at the top of the page.
Any ideas?
Chris
08-18-2005, 05:53 PM
What is appearing exactly?
What is appearing exactly?
include("/your/path/to/file/axs.php")
at the top of the page in just plain text (but with the correct path filled in)
It's like the page is just reading it as text instead of some kind of include. I did make a file with the code at the top of this thread and called it axs.php
Chris
08-19-2005, 07:17 AM
Well I don't know how IPB works on the backend, but with vbulletin I just copy the contents of the file and paste it directly into the php_include_start field of the admin template editor.
I assume that your include statements has <? ?> around it?
Westech
08-19-2005, 07:29 AM
I'm guessing it's as Chris says, you forgot to enclose the statement in <? ... ?> .
Also remember to put a semicolon at the end of the include statement. The whole thing would look like this:
<?
include("/your/path/to/file/axs.php");
?>
And of course, you'll need to change "/your/path/to/file/axs.php" to the correct path to the file on your server.
I'm guessing it's as Chris says, you forgot to enclose the statement in <? ... ?> .
Also remember to put a semicolon at the end of the include statement. The whole thing would look like this:
<?
include("/your/path/to/file/axs.php");
?>
And of course, you'll need to change "/your/path/to/file/axs.php" to the correct path to the file on your server.
I think you and Chris are guessing right. I'm a copy and paste PHP wizard, but I did wonder about that (since I've copied and pasted so much PHP) and tried adding <?path/axs.php but I closed it with a simple >.
I'll go try your code, and thank you!
Well, the good news is that putting in the correct code worked in that it no longer appears as a line of text.
The bad news is that it's not logging anything. I did switch my axs to log my visits and nothing. I changed the code back to the javascript and it started logging again.
I've double checked my paths. I had put the new axs.php file into the root directory. Should it go into the axs folder in the cgi-bin? I also tried chmodding the file to 777 (default was 644).
Chris
08-19-2005, 12:35 PM
axs.php doesn't need to be 777, it isn't writing to itself.
make sure the log file patch is correct. If you put the axs.php file in the same directory has the log file you shouldn't (i think) have to include the full path, just "log.txt", so try that.
Sonnyd
06-20-2009, 09:46 PM
The AXS visitor tracking software has been highly recommended by Chris and others on this forum. It comes with a default javascript module code you place on each page of your site.
Below you will find Chris' PHP module code for AXS. Among its advantages over the javascript is the ability to track search engine spiders as they crawl your site. I find this to be a huge benefit. Note that you do loose the ability to not log your visits using this technique. Chris agreed it could be posted in the forum so here it is... enjoy:
if ($_COOKIE['axs_no_log'] != "1") {
$AXSLogFile = '/full/path/to/log.txt';
$AXSTimeOffsetInHours = +1;
$AXSdomain = 'http://www.yourdomain.com';
$AXSuri = $_SERVER['REQUEST_URI'];
$AXSrad = $_SERVER['REMOTE_ADDR'];
$AXSREMOTE_HOST = @getHostByAddr($AXSrad);
$AXSFrom = $_SERVER['HTTP_REFERER'];
$AXSTo = $AXSdomain.$AXSuri;
$AXSHTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
$AXSunixtime = time() + (3600*$AXSTimeOffsetInHours);
$AXSsecond = date("s", ($AXSunixtime))+0;
$AXSminute = date("i", ($AXSunixtime))+0;
$AXShour = date("G", ($AXSunixtime))+0;
$AXSday = date("j", ($AXSunixtime))+0;
$AXSmonth = date("n", ($AXSunixtime))-1;
$AXSyear = date("y", ($AXSunixtime))+100;
$AXSwday = date("w", ($AXSunixtime))+0;
$AXSyday = date("z", ($AXSunixtime))+0;
$AXSlogline =
"|$AXSREMOTE_HOST|$AXSrad|$AXSFrom|$AXSTo|$AXSHTTP_ USER_AGENT|$AXSsecond|$AXSminute|$AXShour|$AXSday| $AXSmonth|$AXSyear|$AXSwday|$AXSyday|\n";
$AXSfile = fopen("$AXSLogFile", "a");
flock($AXSfile, 2);
fwrite($AXSfile, "$AXSlogline");
flock($AXSfile, 3);
fclose($AXSfile);
}
*** Be sure to make the $AXSlogline = "...."; one line, and no space between the quote and the '|', I don't know why vb is doing that.
Reference:
http://www.websitepublisher.net/forums/showthread.php?s=&threadid=392
http://www.xav.com/scripts/axs/
Hi Guys
I am using this php module with axs, to log
php forum hits, it seems bots are causing this error
8: Undefined index: HTTP_REFERER
Line ==>11: $AXSFrom = $_SERVER['HTTP_REFERER'];
also this error as well
8: Undefined index: axs_no_log
Line ==>3: if ($_COOKIE['axs_no_log'] != "1") {
is there something I can do to correct this?
I am using the exact code above
I didn't change anything.
Thanks
Sonny D
Chris
06-25-2009, 09:01 AM
Try removing making the first variable $HTTP_REFERER instead. I doubt that'll work, but try.
Sonnyd
06-25-2009, 09:15 AM
Problem Fixed
Changed first line to
if (isset($_COOKIE['axs_no_log']) && $_COOKIE['axs_no_log'] != "1") {
Replaced the following
$AXSHTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
$AXSFrom = $_SERVER['HTTP_REFERER'];
With the following
if (isset($_SERVER['HTTP_REFERER'])) {
$AXSFrom = $_SERVER['HTTP_REFERER'];
} else {
$AXSFrom = "User Agent did not provide this value";
}
Hope this helps someone
SonnyD
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.