• Resolved fastfedora

    (@fastfedora)


    Is there a way to exclude views generated by an automated tool? For instance, by excluding any views from certain user agents or excluding views that have a specific query parameter (e.g., wpp_ignore_view=1).

    I’ve started using BackstopJS as a visual regression tool whenever I made update to the site and just noticed that this is inflating my view counts, since every single page on the site is hit with the tool and often I have to run the tool 5-10 times during the process of updating.

Viewing 1 replies (of 1 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @fastfedora,

    Maybe something like this would work:

    /**
     * Don't track page views for a specific user agent.
     *
     * @param  array $post_types
     * @return array
     */
    function maybe_do_not_track_views($post_types) {
    	if ( isset($_SERVER['HTTP_USER_AGENT']) && 'your-user-agent-here' === $_SERVER['HTTP_USER_AGENT'] ) {
    		return array('do_not_track');
    	}
    
    	return $post_types;
    }
    add_filter('wpp_trackable_post_types', 'maybe_do_not_track_views', 10, 1);

    Replace your-user-agent-here with the actual user agent and give it a shot.

    Alternatively you may also want to consider running your regressions tests on a staging / dev environment, this way your tests won’t have any impact on your live site’s views data at all.

Viewing 1 replies (of 1 total)

The topic ‘Exclude views from visual regression tool’ is closed to new replies.