segment-boneyard / analytics-magento

[DEPRECATED] The hassle-free way to integrate analytics into any Magento store.
15 stars 19 forks source link

Product page names should also report title #75

Closed dmulter closed 8 years ago

dmulter commented 9 years ago

A feature suggestion... Product pages only report as the name "Product". It would be much more useful if they also reported more information about the specific product page being referenced.

The following code in app/code/community/Segment/Analytics/Model/Controller/Page.php could be one approach to help:

public function getBlock($block)
{
    $names      = $this->_getCategoryNames();
    $product    = $this->_getCurrentProduct();
    if($names)
    {
        $block->setCategoryNames($names)
        ->setPageTitle('Category Listing')
        ->setFullCategoryName(implode(' -> ',$names));
        return $block;
    }

    $title = Mage::getSingleton('core/layout')->getBlock('head')->getTitle();
    $title = Mage::helper('segment_analytics')->getNormalizedPageTitle($title);

    if($product)
    {
        $title = 'Product: '.$title;
    }

    $block->setPageName($title);

    return $block;
}
sperand-io commented 8 years ago

We're moving away from dynamic page names at the API level, so I'm hesitant to implement this; however, I really appreciate the idea and the report!

We'll likely be making name a spec'd page property field rather than a top level parameter. When we move in that direction in the API we'll adapt the plugin to conform and certainly address this then!