show page views in each webpage

Permalink Browser Info Environment
Hi, just installed, everything works fine, just a question.
We want to show, in footer of each website page, the page view counter.
May i can do that, with a simple php row like that (i used for showing last update of a page)

print $c->getCollectionDateLastModified()

Thanks in advance for your reply

Type: Ticket
Status: Resolved
View Replies:
shahroq replied on at Permalink Reply
There is no built-in API for doing such a thing, but the data is there in the database. You can query the `whaleStatsPages` table manually.
mamarcel replied on at Permalink Reply
Thanks for support.
Now i can view page views in each webpage integrating in the template output of query:

"SELECT hits,CID,SUM(hits) as PageViews FROM `whaleStatsPages` WHERE cID = ".$c->getCollectionID()
shahroq replied on at Permalink Reply
Cheers for sharing.
mamarcel replied on at Permalink Reply
Happy to helping someone else !
Here the complete script I used in my template (not elegant, but functional):
   // Create connection
   $conn = mysqli_connect("localhost", "DBUSER", "DBPWD", "DBNAME");
   // Check connection
   if (!$conn) {
   die("Connection failed: " . mysqli_connect_error());
   // Sort cID of current page
   $IdPagina = $c->getCollectionID();
   $sql = "SELECT hits,CID,SUM(hits) as PageViews FROM `whaleStatsPages` WHERE cID = '".$IdPagina."' ";
   $result = mysqli_query($conn, $sql);
   if (mysqli_num_rows($result) > 0) {
   while($row = mysqli_fetch_assoc($result)) {
      echo "Page Views = ".$row["PageViews"];

concrete5 Environment Information

# concrete5 Version
Core Version - 8.5.4
Version Installed - 8.5.4
Database Version - 20200609145307

# Database Information
Version: 5.7.36-cll-lve

# concrete5 Packages
Traffic & Statistics (1.5.0)

# concrete5 Overrides

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software

# Server API

# PHP Version

# PHP Extensions
apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imap, intl, json, libxml, litespeed, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, Zend OPcache, zip, zlib

# PHP Settings
max_execution_time - 300
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - -1
max_input_vars - 1000
memory_limit - 128M
post_max_size - 64M
upload_max_filesize - 32M
mbstring.regex_stack_limit - 100000
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
opcache.max_accelerated_files - 10000
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.