Reputation: 57
i have static pages created on my site for different articles, but problem is that its not dynamic page, means its just created once and its done. so now m worried how to count page views ? i mean when some user visit through search engine :( the count's did not +1 in database it only records count of page views when someone search that particular page and then come. In this way the users visited via search engine is not counted...
so i got one idea...
that we can put some ping php type code which when visited page any how either through google or any where it will be pinged and it will udpated specific table in mysql...
please guide me...if i m right or not... provide me php code for it...thanks
Upvotes: 2
Views: 2484
Reputation: 1493
Try to install Google Analytics. This implies you insert some JS code into your page, once at the start. Then, each time user opens the page (and doesn't have his JS disabled, which is most probable case) JS fires up and make some secret request to GA, recording this visit.
Once upon a time I've seen a trick to augment TRULY static pages with GA counter, through some PHP preprocessor hooked via .htaccess
, like this: Action text/html /cgi-bin/add_ga.php
. This involved parsing HTML and inserting a couple of <script>
tags into the header, and then serving page to the visitor. Entire directory of static pages, updated independently with any frequency, was hooked to GA this way.
Upvotes: 2