Online Customers is added feature in Magento, which allows administrator to track Online customers, Last url visited and its IP Address.
To use this feature, go to Admin Panel > System -> Configuration -> Advanced -> System -> Log
and set “Enable Log” to “yes“.

But to know location of IP address you need to check whois with that ip adress, which gives you location of IP Address. To view an overall details of location, there is no such feature in the admin grid.
Alternatively, Geo location reports can be availed from google analytics, but here we will not use it.

So, lets add a location column to Online customer grid in Magento Admin Panel.

  1. Rewrite Mage_Adminhtml_Block_Customer_Online_Grid
  2. To add columns in admin grid, add below code to rewrite class Mage_Adminhtml_Block_Customer_Online_Grid in your custom module.

  3. Create Grid.php in your custom module
  4. Add renderer for location
  5. Lets view Online Customer grid
  6. Flush Magento Cache and go to Admin panel > Customer >Online Customer

    magento add column to admin grid

  7. If you want to show a google map on hover of location field
  8. Add a .js file in js folder.

    JS Source: StackOverflow

  9. Add Js file to admin grid
  10. Add below code to your admin themes layout file.

    Now flush Magento cache and view Online Customers grid.

    add column to admin grid magento

So, in this tutorial we explained How to Rewrite a class in Magento ?, How to add column in Magento admin grid and reposition it?, How to add js file in Magento admin?, How to add renderer for grid rows?.

Happy e-magining 🙂