How would you add a step in the AccountController of Magento?

I need to add a tracking code to a Magento template, pretty simple, but I need it on the confirmation page when a user register, but when it does, he’s redirected to the index page, as any user who log in.

I think to add a step by override the account controller because there no such configuration (or I wasn’t able to find it), but even if it’s just a method override of confirmAction to handle the redirect, it doesn’t look like the best way, because this redirect is called several time depending on several things and add session message.

Any ideas?

One thought on “How would you add a step in the AccountController of Magento?”

  1. The only real way I know that you could do this would be to hook into the controller_action_postdispatch_customer_account_createPost event. If you don’t know how to do that, check out this Wiki page.

    In your observer, do something like this:

    // Store a simple boolean that flags this user as just having registered
    Mage::getSingleton('core/session')->setUserJustRegistered(true);
    

    Then, in any footer template, do something like this:

    <?php if (Mage::getSingleton('core/session')->getUserJustRegistered()): ?>
        <!-- INSERT TRACKING CODE HERE -->
        <?php Mage::getSingleton('core/session')->setUserJustRegistered(null); ?>
    <?php endif; ?>
    

    Note that we reset our session variable back to null so that your tracking code doesn’t end up firing on every page.

Leave a Reply

Your email address will not be published. Required fields are marked *