0

I apologize in advance for this being quite a long post... but, any help is great!

I have a website (coded in PHP) which publishes content provided by users in a revenue sharing model.

We pay each contributor a certain amount for every 1,000 "views" that their articles get. In the fine print, a "View" is intended to mean a unique visitor in a 24 hour time period. So if you visit an article three times in 24 hours, they would only get 1 view.

At first, we were tracking views simply by storing a cookie on the users browser. However, the views we were getting were seriously overinflated over the pageviews recorded by google analytic. My guess is because it was recording views for spiders and other robots, which google does not include (right?).

SO, we then switched over to using the google api to track "unique pageviews" for each article. This works very well. BUT, there is a problem:

Many of the articles we publish are broken up into multiple pages. The URL structure is such that each separate page has a unique URL (e.g., /article/21/page-2/this-is-the-article). In order to track the views for a certain article, we aggregate the unique pageviews from each page to one count for the entire article.

So that means that if a visitor reads a three page article, there will still be 3 "views" recorded, instead of the intended 1 (because we want to track unique visitor per article, not page of article).

The question therefore comes down to:

How do we track unique viewers of a single article, even if the article is split over multiple URLS (pages)??

Any help would be greatly appreciated!

3
Contributors
9
Replies
14
Views
7 Years
Discussion Span
Last Post by FlashCreations
0
1. check the valid user if valid get/save his IP.
1. $SERVER['REMOTE_ADDR'] get the ip of the viewer.
2. put the assign "user_id" or "save cookies" to that IP/user.
3. Get the date for today as the day of visit store in one column in your database and track their views with the same date.
4. how about tomorrow?
5. if the "save date" is equal to "server todays date" is equal meaning same date they are viewing the page if not equal grab the system date and overwrite the previous date.

Edited by phpbeginners: n/a

0

Ok... that just sounds like a way to track a unique visitor though, regardless of whether or not it is a robot?

If I am going to track visitors with my own php code, I need a way to differentiate between bots and real visitors.

0

Well by simple logic, why not assume that one unique view is viewing the first page of an article. If so, why not just count the unique views on the first page of each article.

A note about search engine bots: Most search engines identify themselves with a special HTTP header. If you can write your own unique view counter (Cookies will work; it's how Google does it!), simply set it to ignore search engine spiders. Googlebot uses the Useragent String "Googlebot", so simply ignore the view counter when the $_SERVER['HTTP_USER_AGENT'] is "Googlebot".

Read Detecting Search Engine Bots in PHP for more information on search engine spider detection.

Side Note: I would strongly advise against using an IP to track a user. First, if a user is on a large network running through a central router, all the computers on that network would have the same IP address. Large businesses and colleges usually have several IP addresses, but not a unique IP for each computer. This means that if 100 unique people on one network view an article once in a 24 hour period, it will only register as 1 unique view, instead of 100. Beyond this, IP addresses are easily masked. Users can hide behind a proxy or use a client such as Tomato to change IP addresses.

Edited by FlashCreations: n/a

0

they have one IP, but different in registered cookies or user_id's and username right?
tracking IP is good also if you want to banned that user using the same IP :-)
don't just concentrate in IP you have so many factors or fields to considered in your database.

Edited by phpbeginners: n/a

0

Well by simple logic, why not assume that one unique view is viewing the first page of an article. If so, why not just count the unique views on the first page of each article.

A note about search engine bots: Most search engines identify themselves with a special HTTP header. If you can write your own unique view counter (Cookies will work; it's how Google does it!), simply set it to ignore search engine spiders. Googlebot uses the Useragent String "Googlebot", so simply ignore the view counter when the $_SERVER['HTTP_USER_AGENT'] is "Googlebot".

I thought of the first idea you mentioned there, only counting views of the main page. But I'm a little worried that this means users who come in via a search engine to say, the third page, won't get counted. Though, at the same time it might be rare that someone reads the third page without first going back to the first... maybe that will work.

Also, I like the idea of using my own cookie to track visitors, but then you get into the challenge of identifying more malicious bots that might not identify so clearly as google and other major search engines.

0

Well by simple logic, why not assume that one unique view is viewing the first page of an article. If so, why not just count the unique views on the first page of each article.

I checked my statistics, and as a matter of fact about 90% of pageviews for subsequent pages of a multi-page article were coming from previous pages. So, this seemed like a good solution, especially since an additional 4-7% of viewers who landed in the middle of an article ultimately went back to view the first page. Overall, just counting the first page views in counting most unique article views.

0

Another suggestion: If you are worried about search engines accessing pages other than the first, you can either set the robots.txt to allow a web spider access to the first page of every article. You might also want to try setting up a simple script that you include on pages other than the first that checks if the referrer is from a search engine and add some Javascript to manually force Google Analytics to track the user.

If you are satisfied with your solution to the problem, I ask that you close the forum and continue to post on the DaniWeb forums!

-1

if you are worried about bots or some automated system you put a graphics verification in your page. You use "PHP Contact form with image verification"

When you build a form in your web page, you are susceptible to being spamed by automated systems. In order to make sure that the one who completes the form is human, you can use the system with image verification. (from hotscripts)

Votes + Comments
Most of this post is irrelevant and directly copied from hotscripts.com. It shows that the post has no regard to intelligently add to a solved form, but only indicates that the user wishes to increase his/her post number.
0

if you are worried about bots or some automated system you put a graphics verification in your page. You use "PHP Contact form with image verification"

When you build a form in your web page, you are susceptible to being spamed by automated systems. In order to make sure that the one who completes the form is human, you can use the system with image verification. (from hotscripts)

And how is this at all relevant? Yes, spam bots may try a DOS attack with several queries a second, and this would require a CAPTCHA, but this thread has nothing to do with a contact form.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.