fix analytics script and event logging