Refactored google analytics script