By default, Burst will track visits to all pages. In some cases, you might want to exclude some pages. This is possible with a simple filter.
We do this with a simple trick: in Burst, if a hit is detected as being a spammer, the hit is excluded from the statistics. Therefore we can use a filter in Burst, and set a hit to ‘spammer’ if a certain page is visited. This way the hit won’t get added to the database. Add the below code to the wp-config.php file (in this case, you can’t use a mu-plugin, as it will be loaded to late). Replace ‘my-page-url’ with your actual page slug.
/**
* Exclude a page from tracking by setting the referrer to spammer
* Add this function in the wp-config.php, as an mu-plugin is not laoded during the track hit process.
*
* @param $sanitized_data
* @return mixed
*/
function set_referrer_to_spammer( $sanitized_data ) {
$url = $sanitized_data['host'] . $sanitized_data['page_url'];
if ( str_contains($url, 'my-page-url') ){
//we use a trick, by setting the referrer to spammer, this page won't get tracked.
$sanitized_data['referrer'] = 'spammer';
}
return $sanitized_data;
}
add_filter( 'burst_before_track_hit', 'set_referrer_to_spammer' );
You can find the wp-config.php file in the root of your website when you view your website using an FTP client, or a file manager.