Moved analytics code to layout file