CRAIG
CRAIG

Reputation: 1029

Proper Way of Recording Page Views

What is the proper way, using PHP, to record web page views? I believe that currently we just record a view each time a page is hit on, but I am assuming that is including hits from bots, or other things we don't want to be recording.

How can we just record real legit views into our DB and not include stuff that shouldn't be counted as an actual page view?

Thanks!

Upvotes: 1

Views: 119

Answers (2)

Justinas
Justinas

Reputation: 43479

1) Ignore any known bots that visits your web page. (best use robots.txt)

2) Use Ajax call at the end of page to get rid of bouncers (visitors that opens web by mistake and closes it before everything is loaded).

3) I assume you can call Ajax in some delay, so robots will already has left your page and visitor is still browsing it.

4) Record IP addresses and (if possible) some device identifier to find unique visitors.

Upvotes: 0

Piyush
Piyush

Reputation: 4007

Use google analytics

To set up the web tracking code:

Find the tracking code snippet for your property. Sign in to your Google Analytics account, and select the Admin tab. ... Find your tracking code snippet. ... Copy the snippet. ... Paste your snippet (unaltered, in its entirety) into every web page you want to track. ... Check your setup.

Upvotes: 1

Related Questions