Move analytics code to avoid users copying it