public function EventTrackerService::productDetailViews in Commerce Google Tag Manager 8.2
Same name and namespace in other branches
- 8 src/EventTrackerService.php \Drupal\commerce_google_tag_manager\EventTrackerService::productDetailViews()
Track product detail views.
Parameters
\Drupal\commerce_product\Entity\ProductVariation[] $product_variations: The commerce product variations being viewed.
string $list: An optional name of a list.
File
- src/
EventTrackerService.php, line 129
Class
- EventTrackerService
- Track different events from Google's Enhanced Ecommerce.
Namespace
Drupal\commerce_google_tag_managerCode
public function productDetailViews(array $product_variations, $list = '') {
$data = [
'event' => self::EVENT_PRODUCT_DETAIL_VIEWS,
'ecommerce' => [
'detail' => [
'actionField' => [
'list' => $list,
],
'products' => $this
->buildProductsFromProductVariations($product_variations),
],
],
];
$this->eventStorage
->addEvent($data);
}