function _google_analytics_visibility_user in Google Analytics 8.3
Same name and namespace in other branches
- 8.2 google_analytics.module \_google_analytics_visibility_user()
Tracking visibility check for an user object.
Parameters
object $account: A user object containing an array of roles to check.
Return value
bool TRUE if the current user is being tracked by Google Analytics, otherwise FALSE.
1 call to _google_analytics_visibility_user()
- google_analytics_page_attachments in ./
google_analytics.module - Implements hook_page_attachments().
File
- ./
google_analytics.module, line 602 - Drupal Module: Google Analytics.
Code
function _google_analytics_visibility_user($account) {
$config = \Drupal::config('google_analytics.settings');
$enabled = FALSE;
// Is current user a member of a role that should be tracked?
if (_google_analytics_visibility_roles($account)) {
// Use the user's block visibility setting, if necessary.
if (($visibility_user_account_mode = $config
->get('visibility.user_account_mode')) != 0) {
$user_data_google_analytics = \Drupal::service('user.data')
->get('google_analytics', $account
->id());
if ($account
->id() && isset($user_data_google_analytics['user_account_users'])) {
$enabled = $user_data_google_analytics['user_account_users'];
}
else {
$enabled = $visibility_user_account_mode == 1;
}
}
else {
$enabled = TRUE;
}
}
return $enabled;
}