Refactor and add support for ecommerce in analytics