A Micro Micro CMS

Visitor tracking

From September 2020, the tracking file is /inc/tracking.php. Tracking is activated and deactivated in /admin/setup. It can be started, paused, then started again as often as you like. Cookies must be enabled.

Version 3.11 (from 21st December 2020):

In /admin/setup the four options are:

  • (1) 'Track hits' = NO. No hits are tracked.
  • (2) 'Track hits' = YES, 'Track my hits' = empty (left blank). Track all hits, including yours unless you are logged in to admin, i.e. if you are logged in your hits will not be tracked.
  • (3) 'Track hits' = YES, 'Track my hits' = NO. Track all hits except yours even when you are logged out, i.e. your hits will not be tracked at all.
  • (4) 'Track hits' = YES, 'Track my hits' = YES. Track all hits including yours even when you are logged in, i.e. all your hits be tracked.

From Version 3.11 (21st December 2020) view visitor tracking:

Enter the password "v" on: yoursite.com/admin/visits/ (no need to be logged in).

Before Version 3.11 (before 21st December 2020) view visitor tracking:

Enter the password "v" on: yoursite.com/visits/


Hit counts and information per hit

Hit = single visit. There are two reports:

  • Hits per page lists pages visited in order of popularity with number of hits per page.
  • A list of hits showing page, date & time, IP address (with link to geographical information), user info (eg: iPhone, iPad, Android, Windows, Macintosh) and referrer.

Before Version 3.11 the /visits/ folder was in the website root folder but is now in the /admin/ folder. From 3.11 onwards the root /visits/ folder should be deleted. All hits will be reset. When the new /admin/visits/ folder is first viewed, the number of days shown may be calculated as 18618 because tracking needs a start date and there isn't one yet. So if visitor tracking is activated, when viewing a report, begin by pressing 'Delete' to set a start date. That will set the number of days to 1 and the number days tracked will then be correct.

The script counts (i) total hits and (ii) a separate temporary count. To prevent the text file becoming too large, when the temporary count reaches 1000 the hits details are emptied and the temporary count goes back to zero, then starts again. The total hit count is unaffected and is restarted only when all hits are deleted with the 'Delete' button. There is no reason to delete unless you want a new start date (best done just after midnight).

Tracking adds only some 0.05 seconds to serve time compared to 'off'.


The visitor tracking files

From 21st December 2020:

/inc/ (folder)
    /inc/tracking.php

/admin/visits/ (folder)
    /admin/visits/count.txt
    /admin/visits/counts.php
    /admin/visits/delete.php
    /admin/visits/index.php
    /admin/visits/list.php
    /admin/visits/listhits.txt
    /admin/visits/pageid.txt
    /admin/visits/since.txt
    /admin/visits/stylesheet.css
    /admin/visits/tempcount.txt
    /admin/visits/top.php

Notes

(1) count.txt contains a numeral – the total number of hits since all hits were deleted using the 'Delete' button. Unless 'Delete' is pressed, the count will continue regardless.

(2) since.txt is the date when 'Delete' was last pressed and everything was emptied and set back to zero.

(3) tempcount.txt contains a numeral – a 'temporary count' of number of hits up to a maximum of 1000. When 1000 is reached, the numeral goes back to 0 (zero) and the temporary count begins again.

(4) listhits.txt is a list of each individual hit, with details. To prevent the file becoming to large it is emptied each time tempcount.txt goes back to zero.

(5) pageid.txt is a simple list of the $pageID variable for every hit. It is used to generate the 'Page Stats' report on hits per page with a running total. The running total should be the same as the temporary count because the data is emptied and restarted along with the temporary count (at 1000 hits).

Note: if the 'List of Hits' report shows less than 250 hits it means (i) the temporary count recently reached 1000, (ii) all the data except the total count was reset, and (iii) the number of hits recorded since then has not yet reached 250. Alternatively, when 250 hits are shown, there may be many more hits than 250. The 250 display limit is simply a way to keep the report to a manageable size.


A comprehensive report can be obtained with Google Analytics. This involves creating an account with Google and obtaining a 'site tag' which you can add to /inc/tracking.php by replacing:

<!-- Global site tag (gtag.js) (Google Analytics if required) //-->

with the code you obtain from Google – something like:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-00000000-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-00000000-1');
</script>

There is a learning curve if you have never used Google Analytics but the information about the activity on the website is comprehensive (too comprehensive in my opinion).


Prior to Version 3.10:

To make visitor tracking non-active, save /inc/tracking-default.php (or re-name it) as /inc/tracking.php. Nothing will then be tracked.

Information »

Page last modified: 01 February, 2021