You are here

function simple_facebook_pixel_user_insert in Simple Facebook Pixel 8

Implements hook_ENTITY_TYPE_insert().

File

./simple_facebook_pixel.module, line 74
Simple Facebook Pixel.

Code

function simple_facebook_pixel_user_insert(EntityInterface $entity) {

  /** @var \Drupal\simple_facebook_pixel\PixelBuilderService $pixel_builder */
  $pixel_builder = \Drupal::service('simple_facebook_pixel.pixel_builder');
  if (!$pixel_builder
    ->isEnabled()) {
    return;
  }
  $config = \Drupal::config('simple_facebook_pixel.settings');
  $complete_registration_enabled = $config
    ->get('complete_registration_enabled');
  if (!$complete_registration_enabled) {
    return;
  }
  $data = [
    'content_name' => 'registration',
    'status' => 'complete',
  ];
  $pixel_builder
    ->addEvent('CompleteRegistration', $data, TRUE);
}