Best place to include a counter-script?

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
Dawn
Posts: 95
Joined: Tue May 23, 2006 2:10 pm

Best place to include a counter-script?

Post by Dawn »

Hi,

I'm using a counter called "phptraffica" which needs to be included in a place of the script which is loaded at every page.

This 2 lines have to be included:

Code: Select all

// Statistics
$sid="24360";
include("/var/www/vhosts/domain.com/httpdocs/phptraffica/write_logs.php");
The best place would be a place where which identifies the loaded page clearly that I can get the exact stats. But I don't know where...

Greets,
Dawn
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Re: Best place to include a counter-script?

Post by matteo »

Hi,
Dawn wrote:The best place would be a place where which identifies the loaded page clearly that I can get the exact stats. But I don't know where...
[PATH_TO_PMF_INSTALL]/index.php is the write place.
Just add them at the bottom of this file, after:

Code: Select all

...
//
// Disconnect from database
//
$db->dbclose();
Ciao,
Matteo
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
Dawn
Posts: 95
Joined: Tue May 23, 2006 2:10 pm

Post by Dawn »

Thanks for posting :) I've tried it but it doesn't count everything I want when I place it there...

PhpTrafficA isn't only a counter it's a stats script.

I've included my lines in /inc/functions.php at the very end of this file. That works, but it count's unnessesary things like the search for every site. Do you have any other idea?

Perhaps I have to tell you that I'm using mod_rewrite support.

Greets and Thx,
Dawn
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Post by matteo »

Hi,
I do not use PhpTrafficA but before answering you, I downloaded it and read its docs ;).
I need to play some tests if mod_rewrite could be an issue but I guess that it should be something else.

What do you expect from PTA stats, that is to say, what are the pages not currently tracked by PTA adding the code into index.php? The ones of the backend?

Ciao,
Matteo
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
Dawn
Posts: 95
Joined: Tue May 23, 2006 2:10 pm

Post by Dawn »

Hi matteo,

Thanks for your answer and effort. Its really great that you've downloaded phptraffica :)

First I had a problem with the safe-mode, then I turned it off and tried to include my lines again in index.php.

The results aren't really bad but really not perfect too. If I set up phptraffica (to get detailed statistics from every page, with option "cut URL false") I get results like this:

Code: Select all

/faq/search.html 5 views
/index.php 2 views 
/faq/index.php 2 views
/faq/category/4/linux-allgemein.html 1 view
/faq/category/6/befehle_programme.html 1 views 
/faq/content/6/45/de/dat...r_gzip-bzw-tar_bzip.html 1 view
Perhaps you can see the problem:
1. For every page I access it counts a view for search.html. That's not what I want... Because I din't used it.
2. When I access the mainpage of the faq (www.domain.com/faq) it counts index.php (/faq/index.php) what is right but it counts index.php on the root level (???, I didn't include phptraffica a level higher; eg. on www.domain.com) what is wrong.

I know it's only a small glitch but if there is any solutions it would be nice to know it... :)

Greets and best regards,
Dawn
Dawn
Posts: 95
Joined: Tue May 23, 2006 2:10 pm

Post by Dawn »

I fixed this problem on my blog (s9y) which uses smarty too: It includes automaticly the file config.inc.php in the template directory and I had to put the following code inside it:

<?php

// Statistics
$sid="625344";
include("/var/www/vhosts/domain.com/httpdocs/phptraffica/write_logs.php");

?>

Is there a similiar possibility with phpMyFAQ?

Greets and best regards,
Dawn
Thorsten
Posts: 15562
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

yes, but I would use inc/constants.php.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Dawn
Posts: 95
Joined: Tue May 23, 2006 2:10 pm

Post by Dawn »

Thanks for your answer. This works like when I would put the code into the index.php.

The bad thing is when I enter the mainpage (like www.domain.com/faq) it counts search.html too...

Greets,
Dawn
Thorsten
Posts: 15562
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

ah, okay, then you should use main.php.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Dawn
Posts: 95
Joined: Tue May 23, 2006 2:10 pm

Post by Dawn »

Now it only counts hits to the main page (domain.com/faq) but search.html isn't countet, thats true...
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Post by matteo »

Hi,
I'm quite sure that PTA can be configured to avoid tracking some URLs: I'll give priority to PMF bugs ;) and than (maybe the next week, TBD) I'll look at the best way to fit PTA into PMF w/ your requirements.

Ciao,
Matteo
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
Dawn
Posts: 95
Joined: Tue May 23, 2006 2:10 pm

Post by Dawn »

Hi,

I asked at their forum if URL's can be excluded, but it doesn't support this functionality.

Jepp, I think the bugs are a lot more important than this little whish of me, but if you've time it would be really nice if you can look at this problem next week.

Thanks for the great support :)
Dawn
davekuo
Posts: 1
Joined: Sun Dec 30, 2007 7:26 am

Post by davekuo »

HI! How are you all? I am a newbie and just installed phpMyFAQ 2.04 and it is amazing solution! (support UTF-8 Chinese Search!!! ;)

What I would like to do is to include the counter script from Google. I have tried to put it at the bottom of the index.php, but the entire website will turn blank.

I am not sure what do I need to do or if there is any missing syntex since I am not an expert on PHP.

Here is the sample of the Google Counter script

<!-- Google -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-xxxxxxx";
urchinTracker();
</script>


Thank you for everyone's attention and thank you in advance!

Sincerely,

David
Thorsten
Posts: 15562
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

just add it in template/index.tpl.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply