Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-Think skip tracking filter #103

Closed
Zodiac1978 opened this issue Sep 28, 2018 · 10 comments
Closed

Re-Think skip tracking filter #103

Zodiac1978 opened this issue Sep 28, 2018 · 10 comments
Assignees
Milestone

Comments

@Zodiac1978
Copy link
Member

Zodiac1978 commented Sep 28, 2018

I'm not convinced of the usage of the skip tracking filter.

For example: If someone wants to track a Membership site (or community site with BuddyPress) it would be necessary to track logged in visitors. But our approach is to exit the skip_tracking function if the filter is not null.

The user needs to set the filter and he/she needs to copy all the other code lines to just remove is_user_logged_in() which is not as easy as it could be.

https://github.com/pluginkollektiv/statify/blob/master/inc/class-statify-frontend.php#L139-L176

For example:

add_filter(
    'statify__skip_tracking',
    function() {
        if ( is_logged_in() ) {
            // Track logged in users, excluding feed, preview, error and search (skip otherwise)
            return !is_feed() && !is_preview() && !is_404() && !is_search();
        }
	
        // Continue regular processing.
        return null;
    }
);
@Zodiac1978
Copy link
Member Author

@2ndkauboy
Copy link
Member

I agree that the function should be rewritten. There should only be one condition or conditional function in each if block and all of then should be able to be disabled using a filter. And additional filter at the end should allow skipping the teaching due to other conditions.

@2ndkauboy 2ndkauboy self-assigned this Sep 29, 2018
@stklcode
Copy link
Contributor

stklcode commented Sep 30, 2018

Agree on that, however a user should be able to white and blacklist on arbitrary conditions, that's what the hook is for in my opinion.

To not overload the existing hook, we might consider adding a second hook to filter the default settings. like statify__filter_opts( array $opts ).

Thinking further, an array of 9+ booleans is not what comes to my mind when I think of comfort. What about adding a settings page checkboxes instead?
This would really enable the average user to modify the behavior, brings transparency and we can add short info texts to explain each condition.

@Zodiac1978
Copy link
Member Author

Zodiac1978 commented Sep 30, 2018

What about adding a settings page checkboxes instead?

I think that's a great idea!

I stumbled upon another related issue in the support forums (about the first block "Skip tracking via User Agent."):

Statify comes with a default filter that whitelists Windows, Linux, iPhone, etc.
The mobile bots however match this to force mobile display instead of desktop version.

Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4 (compatible; YandexBot/3.0; +http://yandex.com/bots) — Indexing robot.

This behavior should probably be changed in future versions to a more refined blacklist.

Currently the only chance is a custom skip hook or a blacklist plugin to filter their IP subnet. (my blacklist extension does not feature user agent filter either at the moment)

Then there is a block about "Skip tracking via Referrer check and Conditional_Tags.":
is_trackback is not useful, as this is the trackback call itself and no view.
is_robots is not useful, as this the request for the robots.txt file and no page view.
check_referrer is the blacklist check. Making this optional is obviously not useful ;)
is_user_logged_in is useful for a checkbox (see explanation above).
_is_internal is a special case - this function is summarizing four conditionals: is_feed(), is_preview(), is_404() and is_search()

I think is_preview should be already covered through is_user_logged_in, or not?

I am not sure about is_feed(), is_404() and is_search() - should this counted as views? And should we add those metadata for showing counts for Feed, Search and 404s?

2ndkauboy pushed a commit that referenced this issue Sep 30, 2018
@Zodiac1978
Copy link
Member Author

@2ndkauboy I am not sure if you read the two last comments on this ticket.

What about using a user faced setting instead of a filter?

Additionally I don't think that every filter is necessary here. Why do you want to track the visit of the robots file or a trackback call?

And Feed, Search or 404 views should add those info in the database IMHO, so that we can show this info in the dashboard, like the mobile usage mentioned in #104

Maybe we could extend this with more boolean values, like ismobile, issearch and is404.

@2ndkauboy
Copy link
Member

Sorry, I have not seen your latest comments, before I worked on the patches. We could easily remove some of the filters/conditions.

A settings page would be nice, but is also quite a lot of work to be done.

@stklcode
Copy link
Contributor

stklcode commented Oct 1, 2018

I think is_preview should be already covered through is_user_logged_in, or not?

Yes and No.
Logged in users include the JS snippet (for Caching purposes) and this should not happen on preview pages . That's why we split up the checks in two methods a version or two ago.

Sorry, I have not seen your latest comments, before I worked on the patches.

No problem. Your solution is great, if we decide against a settings page.

A settings page would be nice, but is also quite a lot of work to be done.

Hand full of settings API calls and a common Boolean sanitizer is not what I would call "a lot", more of a copy&paste orgy, but you're right. We should evaluate if the effort would bring benefit for more than a few users.

@stklcode stklcode added this to the 1.7.0 milestone Oct 2, 2018
stklcode added a commit that referenced this issue Oct 3, 2018
Added three options to not skip tracking. preview, trackback, 404 and
robots are still hardcoded.
@Zodiac1978
Copy link
Member Author

@stklcode This ticket can be closed after merging #111 - correct?

@stklcode
Copy link
Contributor

stklcode commented Nov 12, 2019

I think so.

Although we probably should either revert the settings for feed and search tracking or document it. JS snippet is not included there, so if those pages are cached, it is far from trivial to consistently track users there. And even if the description does claim that, it would always raise a "why"...

@patrickrobrecht
Copy link
Member

Moved the remaining problems to #137 (feed tracking, not fixable for the JavaScript tracking case) and #138 (search result pages - actually counted, but without the query parameter).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants