You are here

public function PixelBuilderService::addEvent in Simple Facebook Pixel 8

Adds an event.

Parameters

string $event: The event name.

string|array $data: The event data.

bool $use_store: If set to true, an event will be stored in Private Temp Store.

File

src/PixelBuilderService.php, line 102

Class

PixelBuilderService
Class PixelBuilderService.

Namespace

Drupal\simple_facebook_pixel

Code

public function addEvent($event, $data, $use_store = FALSE) {
  $event_data = [
    'event' => $event,
    'data' => $data,
  ];
  if ($use_store) {
    $this->privateTempStore
      ->set('events', [
      $event_data,
    ]);
  }
  else {
    self::$events[] = $event_data;
  }
}