This is a simple web application built using Ruby and Sinatra that allows users to retrieve and display Google Analytics data based on a selected date range. The application utilizes the Google Analytics Reporting API to fetch data such as sessions and pageviews.
- User-friendly interface to select date ranges.
- Displays sessions and pageviews for the selected dates.
- Built with Ruby and Sinatra framework.
Before you begin, ensure you have the following installed:
- Ruby (version 2.5 or higher)
- Bundler
- Google Cloud account with access to Google Analytics
Clone this repository to your local machine:
git clone https://github.com/sakidlo/google_analytics_app.git
cd google_analytics_app
Follow these steps to set up your Google Cloud environment:
- Go to the Google Cloud Console
- Create a new project.
- Enable the Google Analytics Reporting API.
- Create a Service Account and download the
credentials.json
file. - Share your Google Analytics view with the service account email.
Make sure you have Bundler installed. Then run:
bundle install
- Move the downloaded
credentials.json
file to theconfig
directory. - Open app.rb and update the
CREDENTIALS_PATH
variable to point to yourcredentials.json
file:
CREDENTIALS_PATH = 'config/credentials.json' # Update this path if necessary
- Replace
'YOUR_VIEW_ID'
inapp.rb
with your actual Google Analytics View ID.
Start the Sinatra application with the following command:
ruby app.rb
Open your web browser and navigate to:
http://localhost:4567
Sinatra - The web framework used for this project.
[Google Analytics Reporting API] - The API used to fetch analytics data.