logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
judy at Web2Market  
#1 Posted : Monday, May 23, 2022 8:23:55 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 289

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

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

sweeperqb  
#2 Posted : Monday, May 23, 2022 12:44:19 PM(UTC)
sweeperqb

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"); 
}
judy at Web2Market  
#3 Posted : Tuesday, May 24, 2022 6:03:41 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 289

Thanks: 21 times
Was thanked: 5 time(s) in 5 post(s)
Duh. Thanks for the correction.
judy at Web2Market  
#4 Posted : Tuesday, May 24, 2022 6:17:38 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 289

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
shaharyar  
#5 Posted : Tuesday, May 24, 2022 9:09:13 AM(UTC)
shaharyar

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)
You are actually right!
sweeperqb  
#6 Posted : Tuesday, May 24, 2022 3:51:42 PM(UTC)
sweeperqb

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

judy at Web2Market  
#7 Posted : Wednesday, May 25, 2022 5:43:26 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 289

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.
Users browsing this topic
Guest
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.