You are here

public function OfficialFacebookPixelOptions::setUserInfo in Official Facebook Pixel 7

Same name and namespace in other branches
  1. 8 src/OfficialFacebookPixelOptions.php \Drupal\official_facebook_pixel\OfficialFacebookPixelOptions::setUserInfo()
1 call to OfficialFacebookPixelOptions::setUserInfo()
OfficialFacebookPixelOptions::__construct in src/OfficialFacebookPixelOptions.php

File

src/OfficialFacebookPixelOptions.php, line 75
Contains \Drupal\official_facebook_pixel \OfficialFacebookPixelOptions.

Class

OfficialFacebookPixelOptions
Class OfficialFacebookPixelOptions.

Namespace

Drupal\official_facebook_pixel

Code

public function setUserInfo() {
  global $user;
  $use_pii = $this
    ->getUsePii();
  if (0 === $user->uid || $use_pii !== 1) {

    // User not logged in or admin chose not to send PII.
    $this->userInfo = array();
  }
  else {
    $this->userInfo = array_filter(array(
      // Keys documented in
      // https://developers.facebook.com/docs/facebook-pixel/pixel-with-ads/conversion-tracking#advanced_match
      'em' => $user->mail,
    ), function ($value) {
      return $value !== null && $value !== '';
    });
  }
}