The code for the analytics is: