Knowledge Base
  1. Home
  2. Knowledge Base
  3. Advanced Topics
  4. Exclude users from search and visitor data

Exclude users from search and visitor data

If you want to exclude logged in users from search and visitor data, you can use the following code placed in your theme’s functions.php.

This stops search and or visitor data being recorded for that user.

Excluding search data for a specified user

[php]
add_filter(‘ht_kb_record_user_search’, ‘ht_analytics_stop_user_search_record’, 10, 3);

function ht_analytics_stop_user_search_record($record, $user_id, $search_data){
//change this to the user_id of the user to not be recorded
$omit_user_id = 1;
if( $omit_user_id == $user_id ){
return false;
} else {
return true;
}
}
[/php]

Excluding visit data for a specified user

[php]
add_filter(‘ht_kb_record_user_visit’, ‘ht_analytics_stop_user_visit_record’, 10, 3);

function ht_analytics_stop_user_visit_record($record, $user_id, $object){
//change this to the user_id of the user to not be recorded
$omit_user_id = 1;
if( $omit_user_id == $user_id ){
return false;
} else {
return true;
}
}
[/php]

 

Was this article helpful?
Related Articles