Upgraded analytics script