content-data-api: Set up Google Analytics credentials in development
To be able to import data from Google Analytics, a few environment variables need to be set.
- Create files
N.B. This file has been added to
.gitignore, so you don't need to worry about accidentally checking it in.
local_env.yml is used to
- Create the environment variables required to connect to and query the Google API for Google Analytics
- Store your Google API credentials. They can either be downloaded from the google developers console or from another team member.
- Add an entry to
config/local_env.ymlfor each of the following:
This will make "1234567" available as
GOOGLE_ANALYTICS_GOVUK_VIEW_ID is the view id on Google Analytics for
See "Option Three" in Rails Environment Variables for more information
Update facts table with GA metrics
To populate GA metrics for a given day, open a Rails console and run:
It is recommended you disable logging to speed up the process:
Google::Apis.logger.level = Logger::ERROR ActiveRecord::Base.logger = nil