You are here

function google_analytics_user_id_hash in Google Analytics 8.2

Same name and namespace in other branches
  1. 8.3 google_analytics.module \google_analytics_user_id_hash()
  2. 7.2 googleanalytics.module \google_analytics_user_id_hash()

Generate user id hash to implement USER_ID.

The USER_ID value should be a unique, persistent, and non-personally identifiable string identifier that represents a user or signed-in account across devices.

Parameters

int $uid: User id.

Return value

string User id hash.

1 call to google_analytics_user_id_hash()
google_analytics_page_attachments in ./google_analytics.module
Implements hook_page_attachments().

File

./google_analytics.module, line 372
Drupal Module: Google Analytics.

Code

function google_analytics_user_id_hash($uid) {
  return Crypt::hmacBase64($uid, \Drupal::service('private_key')
    ->get() . Settings::getHashSalt());
}