-
☆ A M B ☆
- 1,231 Posts
Looking at this counter... I need one that works for individual pages rather than a blanket count.
-
☆ A M B ☆
- 1,231 Posts
Quote from: bob1000 at Jul 07, 2008, 09:37 AM
I don’t see why Page Hit Counter won’t work for you. It does just that, counts the number of times a page has been viewed. It just doesn’t display the count on the web page.
Try installing the page counter module and plugin and then use it with this snippet:
<?php
$prefix = $modx->dbConfig['table_prefix'];
$page = '';
$page_id = isset($id) ? $id : $modx->documentObject['id'];
$sql = "SELECT page_count FROM " .$prefix. "page_hit_counter WHERE page_id ='" .$page_id."'";
$rs = $modx->db->query($sql);
$row = $modx->db->getRow($rs);
$page .= "Page views: " . $row['page_count'];
return $page;
?>
Create a new snippet called pageCount or something and add that code, then call [!pageCount!] wherever you want the count to appear in your document.
It’s a very basic snippet but it works on the test I did.
Hey thanks for the idea here... I have the Page Hit Counter module installed and it’s displaying counts in the manager but not on a webpage. It’s showing the Page Views line from the snippet but not the info from the module...
-
☆ A M B ☆
- 1,231 Posts
Thanks bob, that worked! How accurate is the page counter anyway?
You’re welcome, anything to help. I’m sure that script could be improved a lot, I’m not a programmer so it could probably be written much better.
I don’t know how accurate page counter is, I haven’t really looked at the code. In my experience of the different stats and analytics software I’ve used in the past, they all give slightly different results. I find them more useful as a relative measure rather than for definitive results.
-
☆ A M B ☆
- 1,231 Posts
Yeah it’s good of you, thanks. It’s not imperative that the stats are 100% correct. Anyway I just sat and held on to my refresh button on 1 of my test pages and it counted every refresh so seems to be pretty decent.
Ross