public function SendOrderAnalyticsSubscriber::sendOrderAnalytics in Commerce Google Analytics 8
Sends the Ecommerce tracking data using GA Push API.
Parameters
\Drupal\state_machine\Event\WorkflowTransitionEvent $event: The event we subscribed to.
File
- src/
EventSubscriber/ SendOrderAnalyticsSubscriber.php, line 31
Class
- SendOrderAnalyticsSubscriber
- Sends Ecommerce tracking data to google analytics when an order is placed.
Namespace
Drupal\commerce_google_analytics\EventSubscriberCode
public function sendOrderAnalytics(WorkflowTransitionEvent $event) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $event
->getEntity();
// Build the GA Push array.
$ga_push_params = $this
->buildGaPushParams($order);
// Push a GA ecommerce using GA Push module API.
// @see ga_push_add_ecommerce()
ga_push_add_ecommerce($ga_push_params);
}