You are here

protected function Event::doExecute in GA Push 8

Executes the action with the given context.

File

src/Plugin/RulesAction/Event.php, line 55

Class

Event
Provides a 'Ga Push Event' action.

Namespace

Drupal\ga_push\Plugin\RulesAction

Code

protected function doExecute() {
  $event = [
    'eventCategory' => $this
      ->getContextValue('category'),
    'eventAction' => $this
      ->getContextValue('action'),
    'eventLabel' => $this
      ->getContextValue('label'),
    'eventValue' => $this
      ->getContextValue('value'),
    'nonInteraction' => $this
      ->getContextValue('non-interaction'),
  ];

  // Retrieve selected method or the default one.
  $method = $this
    ->getMethod();
  if ($this
    ->isDatalayerMethod()) {
    $event['event'] = $this
      ->getContextValue('event');
  }
  ga_push_add_event($event, $method);
}