How handle bot to count pageviews - algorithm

I don't know how exactly handle this situation. I have a directory where I count the pageviews for each item. For authenticated users I only count as new pageview after a delay of 200 seconds between requests. For unauthenticated users I use the IP and also 200 seconds of delay.
I use a redis SETEX to verify and then the key will expire after 200 seconds. If the key doesn't exist, then insert a new page view.
Something like this
item_id:user_id (authenticated users)
item_id:ip (unauthenticated users)
Well, this works fine until a user try to increment intentionally the page views for a specific item. I have almost 3000 views for a specific item only yesterday (in last year the page has only 150 views...). So, he created some bot to visit the page with a delay to avoid my validation.
I need to register legit pageviews, but I need to avoid the type of fraud. Any idea?

As far as I know, the best way for handling bots is a way like Google Analytics.
Google Analytics works by inserting a JavaScript snippet into the
header of your website. This snippet counts a page view whenever a
visitor triggers that JavaScript, and most bots do not process
JavaScript.

You can integrate some kind of CAPTCHA in your application to limit the number of times a user can view the page within a specific amount of time.
Upon a set number of views within a given duration (say, 20 views in under 3 minutes) from the same user or IP, make them verify the CAPTCHA each subsequent time they try to view the page.

Issue a Token for every page view request. Store the token in the Cookie.
User your already available IP or USER_ID as a filtering mechanism.
After page loaded, User the token, old_token from the cookie, Operating System, Browser Name and IP / User_ID to validate the request.
Give two different timings, like 200 second expiration time and 3600 seconds of grace time, if any of the above data matches within the grace time, don't count the page view.
You can also extend this by keeping track of page views within grace time and create some methods to validate pageview request.

I usually register the Request Time together with the Request to measure the Visit Frequency and the Visiter Count per certain Time Span.
When you register all the Request that come in with with the item_id, user_id, ip and timestamp you can afterwards process the Registers by grouping them by user_id, ip and timestamp.
That way you can find out the amount of Hits per Second and identify and exclude those who clear surpass the normal Activity Pattern without loosing Data.
Often I use the Web Service Logs to generate Statistics about Visit Frequency to certain URLs on a hourly, daily or even monthly basis.

Related

Restrict access to a page when event fires

i have created a booking system which synchronizes with Google Calendar every 5 minutes and also truncates and old data and fetches new one from calendar, this process takes about 2-3 seconds.
What i want to do is, when the event to fetch data from Google Calendar fires, i want to disable access to the route of the booking system for these 2-3 seconds then enable it again when the event ends, i want to do this because it truncates the old data and fetches new one, so if a person is looking at the booking system this 2-3 seconds all the book schedule times will be free and i don't want this to happen.
Is this kind of thing possible?
Thanks and regards!
Well, my suggestion is to create a new field in your users table something like : is_google_sync_active and route middleware.
Then just before you will start sync. you change that field to true and in your new middleware you may check whether your sync. is active or not, then when your sync. ends you just change the value of field again to false. So, every time when user tries to pass to your sync route he will be passing your middleware which wil handle all job.
In addition, you can redirect user to page which shows status or progress if the sync. is processing.

Want to build an attendance management system using MEAN stack

I want to build an attendance management system using MEAN stack. The application should work like this -
There will be an admin who will control CRUD operations on User and as well as look into the Attendance of each user and have a detailed list of average attendance of the user per month and per year.
There will be a user page and when the user logs in i want to store the date and time in the client side and then send it to the database. So that based on the time and date the admin can see when the user has logged in and mark the user as present for that particular day.
I want to know how to store the date and time in the client side and then pass it onto the database for calculations. Also wanted to know that is it necessary to authenticate in the front end as well?
May be I am late, but I can try to answer your query.
You can store date and time as an object and pass it via request parameters to the backend to store it in the database.
You can take a look a the following on how to get date and time in Javascript How do I get the time of day in javascript/Node.js?

Event Before the Record is changed in MS Access

I have an MS Access Form where I have two subforms. I need to be able to run a code/query before the record is discarded.
This DB is for tracking a hotel's sales and payments. The bounded form has the following layout:
First we have the main form with global fields like, ClientID, client name, address, bill date, restaurant bill, spa charges, etc.
Then I have the rooms subform (Datasheet view). This form has all rooms allotted to the guest. It also has the number of days charged and Rate fields.
Lastly I have a payments sub form (DataSheet View). It has all payments received from the guest. Last Tab index is for the payments Subform. I need to find the total amount the customer was billed. (sum of all room rate X number of days + Money Spent in Spa + Restaurant Bill). I also need to find the sum of all payments. If the total payment is different from total bill then I need to prompt the Operator to confirm the addition.
I know the VBA codes and queries to process the above. But what I do not know is how to trigger this event. I tried AfterUpdate, but it is fired the moment I move to any Sub Form. I need the code to run after the Operator has made all changes and is ready to move to the next record. I am at a loss on how to accomplish this.
You could just place the function in the after update of the last field in the operator's workflow on the last subform?
Alternatively, place a check to run the code on your move next/prev buttons to ensure the operator has completed the entirety of the workflow?
Could you post a ss of the form(s) so I can get a visual picture :)?

In Google Analytics, why are Unique Pageviews higher than Sessions if it can only fire once per session?

I think I get the different between Users, Sessions, and Pageviews in Google Analytics.
A Visitor/ User can start several sessions even in the same day, of a website ... and each session is comprised of visiting many pages, possibly more than once.
Here's the confusion ... what the frack is the difference between Unique PageViews and Sessions, when applied against a certain page?
A Unique Pageview is basically --- was the page viewed at least ONCE during the session? If yes, +1, else, +0. Isn't that IDENTICAL to sessions?
At least, for an individual page.
I know you can visit 4 unique pages during a session, but a specific page should have the two things equal, right?
The report seems to be presenting the correct data.
Here is how I understand it : - For a given page, the Unique PageView counts the number of sessions that displayed this page one or more times. Unique Pageviews is the number of sessions during which the specified page was viewed at least once. A unique pageview is counted for each page URL + page Title combination.
But it is not how it shows in the case you have presented
Vs
In actual it shows Sessions and Unique Pageviews different.
Our explanation is that the unique pageviews are being shown in funnel which is same as Sessions but when applying filters based on session, you are being shown the session with Entrances on that page for some reason.
To confirm this – you can test adding a segment as shown below and match the output numbers.
1. When you check segment on a page, the session count is 5562 (as the report) I.e. all sessions in which that page was viewed.
When you check segment on a landing page, the session count is 600 (close to the filter report 589) I.e. all sessions in which that page was the landing page.
Ideally we also expect to see the number to be 5562, in the filtered view under the ‘sessions’ metric when we filter on a single page. Also, we expect the sessions to be same as unique pageviews but somehow the metric shown is referring to the ‘sessions that started with that page’ i.e. entrances.
Here is your actual answer, I think! :)
http://help.analyticsedge.com/googleanalytics/misunderstood-metrics-sessions-for-pages/
Basically, if you filter sessions results down to a page, you will see a count of how many sessions started on that page. (Sessions only get attached to the Entrance page).
Cheers.
The Unique Pageviews metric is an approximation of how many times the page has been viewed by a unique user in a given time period. By default, Google Analytics tracking cookie will remember a user on a device for 30 days, unless the user deletes cookies or uses a different device.
Sessions, on the other hand map to Entrances are is a metric that approximates how many times a given page-based dimension was the first hit of a session. A session is defined as an active period of browsing activity by a user of your site. After the session is initiated (someone comes to your site), the session timer will continue to run until either a)the user leaves your site, or b)there is a period of inactivity that lasts for 30 minutes. In either of those cases, the session will be closed. A new session would start when the user resumes activity after that 30 minute period of inactivity, or when they come back to your site.
This behaviour is expected behaviour.
The sessions count is the number of sessions who landed on that screen/page.
The unique page views are the number of sessions who viewed that page.
Eg.
Home screen: 100(sessions) 1000(unique page views)
Interpretation: 100 sessions landed on the home screen and 1000 sessions viewed the home screen( remaining 900 landed on some other screen but eventually viewed the home screen.
This is my understanding:
User A visits Page P1:
Page
Page views
Unique page views
User
Session
P1
1
1
1
1
Same session, user A visits page P2 from page 1 (P1):
Page
Page views
Unique page views
User
Session
P2
1
1
1
0
Notice the session count for page P2 does not increase (0) but unique page views for page P2 is 1.
I believe, because of cases like the above unique page views are greater than sessions count.
You can use this simulator for further understanding.

How to implement cookie, user -tracking in grails?

I'm working on a affiliate system in grails where users can create individual links and guests who are visiting this links get an cookie with an unique session id. If some of the guests come a few days later to my webApp again i want to know that they've been here already and wich user brought this guest to my website in the past.
How would you implement this in grails? I would say with filters. But how should i implement such a filter? Using the grails default session id wouldn't be good, because it gets invalidated and i can't upgrade the grails session lifetime as much because of the servers memory (RAM). Or is the sessionId always there and gets only refreshed, so the session lifetime in grails could be 1 hour and i'm able to track everything longer than an hour too?
Or should i set a new cookie with a unique session id especially for my purpose?
You probably need at least one filter and one cookie.
When the visitor comes to your site for the first time, I'm imagining that you define the affiliate ID as a request parameter. You probably need to create a before filter to see if the visitor already has a cookie set.
If you're just trying to associate sales with an affiliate then you don't need a unique visitor ID, just the affiliate ID that referred the visitor. Inside your filter, if the affiliate ID request parameter is present but there is no cookie, you can set the cookie. Then, when you are processing a sale, you can check if the affiliate cookie exists.
If you are trying to get more advanced metrics then you probably will need two filters (or one filter that does 2 things). One to set the cookie, and one to track the visit. Once you know the things you want to track, you can also put flag's in the user's session to keep your metrics accurate (i.e. if you don't consider each request a visit you may want to put a flag in the user's session after you increment the number of visits for the visitor.)

Resources