I want to insert tracking codes on all of the pages of a Magento site, and need to use a different syntax if the page is a CMS page, a category browsing page, or a product v
I thought it would be worth mentioning there is a flaw to checking
Mage::registry('current_product')
This does indeed check if a product exists, but when on a review page for example, the product is also set, therefore you may need to be more specific to determine the page location.
The following check ensures we are on a product page, by checking it is using the "catalog" module, and the controller is a "product" request. When viewing a products list of reviews it's values would be "review" (module) and "list" (controller).
if($this->getRequest()->getModuleName()=='catalog' &&
$this->getRequest()->getControllerName()=='product'){
Mage::registry('current_product');
}
I hope this helps.