Refine analytics code error