Search code examples
magentoregistrationreferrer

Magento customer_register_success Observer, get referral page


I have an observer in Magento that fires whenever the customer registers a new account. What I would like to do is find out if that registration came from checkout, or from the normal registration page. What can I call from the observer to find which page the registration referral came from internally?


Solution

  • You could save the last X pageviews in magento registry by putting something like this into some PHP code which is executed each time.

    $urlHistory = (array) Mage::getSingleton('core/session')->getMyUrlHistory();
    while (is_array($urlHistory) && count($urlHistory) > 3) {
        array_shift($urlHistory);   
    }
    $urlHistory[] = Mage::helper('core/url')->getCurrentUrl();
    Mage::getSingleton('core/session')->setMyUrlHistory($urlHistory);
    

    You can then analyse Mage::getSingleton('core/session')->getMyUrlHistory() within your observer.