Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
I'm trying to turn off registering a page visit if there are no cookies, like you do for the bot guid code. We have source code and I have added private void RecordPageRequest(HttpApplication application, HttpContext context) { ApplicationSettings appConfig = AblecommerceConfiguration.Instance.ApplicationSettings; StoreSettingsManager settings = AbleContext.Current.Store.Settings;
// CHECK IF TRACKING MODULE IS ENABLED FOR THIS PAGE if (appConfig.PageTrackingEnabled && settings.PageViewTrackingEnabled) { // EVALUATE THE RESPONSE AGAINST THE SETTINGS. bool isValid = this.IsValidRequest(application.Request, appConfig); //jme don't register page view if there are no cookies to try to lessen impact of BOTS bool foundCookies = !string.IsNullOrEmpty(context.Request.ServerVariables["HTTP_COOKIE"]); Logger.Warn("Found cookies is " + foundCookies.ToString()); if (isValid && !foundCookies) { try { Logger.Warn("Shouldn't be saving pageview"); // RECORD THE PAGE REQUEST
The entry in the log says Shouldn't be saving pageview, but the page view gets saved anyway.Am I doing something wrong or is there another piece of code that saves the pageview? I am using Edge and I have turned off cookie storage and have specifically blocked cookies for my local site and it shows there are no cookies saved in the browser settings. Thanks
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Judy, The code you posted seems off. You check to see if cookies are found and output to the logs the value of that flag. Then you have an if condition which checks to make sure the request is valid and that no cookies were found. So then you are recording the request only when it is valid and there are no found cookies. Based on your description, I think this might be what you are after: Code:if (isValid && foundCookies)
{
// RECORD THE PAGE REQUEST if it is valid and cookies are found
}
else
{
// DO NOT RECORD THE PAGE REQUEST if not valid OR no cookies are found
Logger.Warn("Shouldn't be saving pageview");
}
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
Duh. Thanks for the correction.
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
Been thinking- I don't want to log the request if there are no cookies. That is how AC handles their BOT GUID user- lack of cookies is indication that it is a bot. My logging should be Should be saving page view instead of Shouldn't
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 5/30/2020(UTC) Posts: 125
Thanks: 14 times Was thanked: 3 time(s) in 3 post(s)
|
Judy, not sure how important it is, but it is worth noting that when a user first enters the site they will not have a cookie. You are going to have to weigh whether it is more important to remove all bot views or lose the first view of every new user. Also, several bots are now smart enough to save and resend cookies. Since they can send whatever they want for the user-agent, save/send cookies, and even do some JavaScript, there is no longer a foolproof method to fully filter out bots. Edited by user Tuesday, May 24, 2022 3:56:07 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
Thanks. I was seeing that from the page views after implementing the code. I had just followed AC pattern of determining bots- I think I'll have to try to find another way of determining bots. I think I had assumed that a user coming to the site for the first time would probably have cookies from somewhere. I had noticed after implementing the code that there were entries in the page views table that had bots in user agent.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close