Refactoring Google Analytics API connection