How to add a site hit/visit counter to Drupal website?

How to add a site hitvisit counter to Drupal website

Looking for site hit counters to add to your Drupal website? Have you tired out some modules already? Some feel that there is no need to add site hit counters while some feel they should add. It's all up to you. Many websites still do. And though there are other ways to monitor site visits such as via Google Analytics. But placing a site visit counter could let us know if there has been any hits right from the page instead of using another service. In this post, we shall see how to add site hit counters to Drupal website easily.

For Drupal platform, there are very few modules related to site hit/visit counters. And as per my test, I found they are not that convenient to configure and most of them are just overkill when all you really want is a simple site hit counter. But that is just my opinion. Here are some Drupal site hit/visit counter modules which you might have already tried. Or if you haven't, check them out. At the end of this post, we shall also see another way to install site hit/visitor counter on Drupal website without installing a module.

Some modules available on related to site hit/visitor counter:
The module page says -
This module records various data about (anonymous or authenticated) visitors of a Drupal site, and shows these data in the format of either Reports (with charts) or Blocks.
Using this module, the visitors block displays the following information:

Visitors Block

  • Total Visitors.
  • Unique Visitor.
  • Registered Users.
  • Last Registered User.
  • Published Nodes.
  • Your IP.
The module also generates the following reports:

Reports (with charts)

  • View pages that have recently been visited.
  • View pages that have been hit frequently.
  • View pages count per month.
  • View pages count per day of month.
  • View pages count per day of week.
  • View pages count per hour.
  • View pages count per host.
  • View access log.
  • View user activity report (hits, nodes, comments).
  • View referrer list.
When you just want to display total visitors, this module seems like an overkill. You may install this module and test it if it meets your requirement. Also do check out the issues open here before implementing on live site.

The module page says -
Counter module counts how many visitors on your website. This module provides real time counting. All data saved to database.


  • Count Site Counter per day, minute even second!
  • Count Unique Visitor
  • Count Registered and Unregistered User
  • Count Published and unpublised Node
  • Display Web Server IP and Client IP
  • Report: Client IP, Access Date, Access Page
  • Initial values
  • Visitor Statistic per day, week, month and year!
  • Support Views module
  • Saved fields: nid, content type, browser name, browser version and platform
If all you need is a simple visitor count, this module again seems like an overkill. But if you need the details, you may check it out. Do see the issues here prior to implementing on live site.

Drupal 7 includes a statistics module, which is now a part of Drupal core, which can be enabled and admins can check site hits information besides a lot more. The Statistics core module overview page says -
The Statistics module shows you how often a given page is viewed, who viewed it, the previous page the user visited (referrer URL), and when it was viewed. These statistics are useful in determining how users are visiting and navigating your site. - link
But by this method, the hits cannot be displayed publicly in a page or in a block as per my experience. If this is wrong, do correct me. To use Drupal statistics, enable the "Statistics" if not already enabled. And Configure statistics via configuration > system > statistics.

Some other related modules includes -
From my experience with these modules, I found that these modules are too much information when all I needed was a simple total visits counter. If you have similar needs, then we have to find some other ways to display the hit counter. Besides, the another issue of installing modules is that if you can't customize or if there are some issues encountered, you are dependent on others to provide a fix if you can't do it yourself.

Site Hit/Visit counter for Drupal without installing modules

If you are in need of site hit/visitor counter and do not want to install modules, then you can develop your own custom module, or use some PHP code or use online services that offers site counters. Even here, there is still dependency on the service provider if in case they choose to shutdown their service. But as long as the serivce is up, at least you will get a simple site counter for your Drupal site.

I use StatCounter's site hit counters for my projects, and they work as expect. They are simple, just the way I wanted.  StatCounter provides free customizable hit counters, visitor tracking, web analytics and website stats for Drupal. They also have an official Drupal module - StatCounter Module on
The module allows users to insert their StatCounter tracking code and select the scope of pages they wish to display it on.

Steps to install SiteCounter's site hit/visitor counter on Drupal Site:
  •  Sign up for a free account
  •  Add a project and enter the website URL
  • Enter Website Name and setup country, timezone etc.
  • Choose a counter type - Visible Counter, StatCounter Button or Invisible Tracking. You would want to choose "Visible Counter" to display the counter on the Drupal site.
  • Customize the counter's size, text color and background.
  • Opt in or out of reports by email. I opted out as I do not need it.
  • StatCounter has an installation guide for Drupal too. Click on the Drupal icon.
  • Chose the type - Standard, Standard (xhtml), Basic, Basic (xhtml)
  • Copy the code


On the Drupal website:
  • Log into your Drupal website.
  • Under Structure> click "Add Block".
  •  Enter "StatCounter" as the "Block Description" and paste your StatCounter code into the "Block Body".
  •  Make sure that your "Input Format" is "Full HTML" then scroll to the end of the page and click "Save Block".
  •  Add the block to the footer area of your website or in any other region desired. Scroll down the page to locate your new StatCounter Block.
  •  Click "Save Blocks" and that's it!

Your StatCounter will now begin recording visitor information and, if you chose the visible option, your counter will be visible on your website. Reload your homepage; you should see the StatCounter counter on the page.

The screenshot below is from a live Drupal site displaying StatCounter hit counter.


Comment with Facebook


  1. Dear,

    I'd like to recommend a free web counter for you.
    It has 25 beautiful styles to choose from.
    The URL is:
    I wish you like it.

    Best wishes,


Post a Comment