In some scenarios a product_catalog_id is not neceassary. However, if it is not added in admin it breaks the tracking code since there is an empty value in frontend a la ''product_catalog_id: }"
Better check if catalog_id is set before adding it to the tacking code. This can be done by moving it to a extra function like that:
protected function getProductCatalogId() { return (Mage::helper('hevelop_facebookpixel')->getProductCatalogId()!='') ? "', product_catalog_id: " . Mage::helper('hevelop_facebookpixel')->getProductCatalogId() : ''; }
In some scenarios a product_catalog_id is not neceassary. However, if it is not added in admin it breaks the tracking code since there is an empty value in frontend a la ''product_catalog_id: }"
Better check if catalog_id is set before adding it to the tacking code. This can be done by moving it to a extra function like that:
protected function getProductCatalogId() { return (Mage::helper('hevelop_facebookpixel')->getProductCatalogId()!='') ? "', product_catalog_id: " . Mage::helper('hevelop_facebookpixel')->getProductCatalogId() : ''; }
And call it in the code function like that:
$pixelCat = "fbq('track', 'ViewContent', {content_category: '" . addslashes($currCat->getName()) . "', content_ids: ['" . implode("','", $productIds) . "'], content_type: 'product'". $this->getProductCatalogId() . "});";