Move analytics out of template into cached script