Reputation: 11
I want to display a counter on my website. The counter is to be done using Drupal, not by external providers. On the net I've found these instructions:
Drupal 7 - Hit/Page View counter for Articles Another task I had to spend more time that I needed to. You would think that a simple hit counter would be a readily availble in a modual. Anyway, heres what ya do:
1) It's part of core; enable the core "Statistics" module. You can see the official notes at : http://drupal.org/project/statistics_advanced
2) Go to: Administration » Configuration » System » Statistics. You may have to enable the "Statisctics" modual first.
3) For the setting "Content viewing counter settings" check the "Count content views" checkbox.
4) Be sure to set permissions for the module at admin/user/permissions, and configure it in admin/settings/statistics. IMPORTANT - On the giant Permissions panel, scroll down to the "Statistics" mod and enable permissions for "anoymous user" and "authenticated user"
5) You can now show the total count of the page hits, it should display in the block region you assigned.
IMPORTANT - The block name is called "Popular Content". Dont ask why. You can see it working below:
5399 reads
I moved the popular content block into the correct region but it will not show me the number of hits only the most popular content pages. I would like to be able to show the number of hits.
Alternatives?
How about a php-script?
But where to put it: http://my-drupal-site.com/...path???.../counter.php
What is the html-code to run the script and to show the result?
(Please if you reply be aware of: I am drupal newbie,
experience status:
php: no
html, css, linux, bash programming: yes)
Thanks
Upvotes: 1
Views: 7087
Reputation: 1
I have solved this issue. I have got the unique visitor count per node using "nodeviewcount.module". Just install this "nodeviewcount.module" module and then in my page.tpl.php I just fetched the result with the below code.
<?php
$query = 'SELECT COUNT(DISTINCT uid) FROM {nodeviewcount} WHERE nid='.$node->nid;
$unique_visitors = db_query($query)->fetchField();
print $unique_visitors.' views';
?>
I think this might help you.
Upvotes: 0
Reputation: 948
You can use the visitors module to display the amount of visitors.
The module provides the following blocks:
Upvotes: 1