Reputation: 759
In /app/code/core/Mage/GoogleAnalytics/Block/Ga.php line 88 makes reference to $this->getPageName() which is used in line 95 of the same script. While this makes sense in that if the page has a "Page Name" defined it will attach it to the Google Analytics code what I can not find is where in the Magento Admin or the page XML do I set this "Page Name" for a CMS page? In the notes on Ga.php it says "The custom "page name" may be set from layout or somewhere else. It must start from slash." but I don't see how I would do that.
When I asked this question to Magento Support they came back with "Look at our design guide" and no other information.
How do I set a Page Name for a CMS page in Magento Enterprise 1.12.0.2? Thanks!
Upvotes: 1
Views: 401
Reputation: 9224
Another solution, based on Roscius version:
public function getPageName()
{
if (!$this->hasData('page_name')) {
$this->setPageName(str_replace(Mage::getStoreConfig('design/head/title_prefix'), '', $this->getLayout()->getBlock('head')->getTitle()));
}
return $this->getData('page_name');
}
Upvotes: 0
Reputation: 1534
It's not set anywhere by default. You could set it when you create the block in the layout xml using an action call eg:
<action method="setPageName"><name>blah/blahblah/foo.html</name></action>
You could set it in a controller by calling the setPageName() method on the block. Or you could just override the Mage_GoogleAnalytics_Block_Ga class and add your own custom functionality:
public function getPageName()
{
if (!$this->hasData('page_name')) {
$this->setPageName(Mage::getSingleton('core/url')->escape($_SERVER['REQUEST_URI']));
}
return $this->getData('page_name');
}
Upvotes: 1