You are here

public function GoogleAnalyticsAccounts::getUserIdHash in Google Analytics 4.x

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.

File

src/Helpers/GoogleAnalyticsAccounts.php, line 66

Class

GoogleAnalyticsAccounts

Namespace

Drupal\google_analytics\Helpers

Code

public function getUserIdHash($uid) {
  return Crypt::hmacBase64($uid, $this->privateKey . Settings::getHashSalt());
}