We are using below code from this github extension for tracking meta facebook pixel events in our Magento PWA Venia Site.
$product = $this->registry->registry('current_product');
if ($product && $product->getId()) {
$customData['value'] = $this->_magentoDataHelper->getValueForProduct($product);
$customData['content_ids'] = [$product->getId()];
$customData['content_category'] = $this->_magentoDataHelper->getCategoriesForProduct($product);
$customData['content_name'] = $product->getName();
$customData['contents'] = [
[
'product_id' => $product->getId(),
'item_price' => $this->_magentoDataHelper->getValueForProduct($product)
]
];
$customData['content_type'] = ($product->getTypeId() == Configurable::TYPE_CODE) ?
'product_group' : 'product';
}
Here is full code : facebook/facebook-for-magento/Observer/Viewcontent.php : https://pastebin.com/5Dk698ex
Issue :
We can not able to fetch the View Content Pixel in PDP Page. Only PageView is fetching.
We are getting only PageView in PDP Page :
But We need below ViewContent :