View and export your Universal Analytics data before the API is disabled on July 1, 2024. This tool simplifies data exportation from Universal Analytics, allowing for flexible data retrieval in any format (by default CSV & JSON). Plus, this tool also allows you to do the same with your GA4 data, making it easy to both view and export your data well into the future.
This project uses Next.js and Material UI. Ensure you have Node.js and nvm installed. Then run:
git clone https://github.com/kyco/google-analytics-viewer
cd google-analytics-viewer
nvm use
npm install
Start the project locally:
npm run dev
Access it at http://localhost:3000.
After the app is running locally you will need to hook it up to the Google services in order to retrieve data.
NB: For all the steps below when navigating in Google Cloud Console ensure you have the correct project selected!
If you don't have a service account, create one (we will need the JSON file later on):
Enable the required APIs:
Copy the client_email
from your service account file and add it as a "Viewer" via the Google Analytics UI:
- Admin > Account Access Management > Add users
Create .env.local
in the root of the project:
GA_UNIVERSAL_VIEW_ID=<your_universal_view_id>
GA_PROPERTY_ID=<your_ga4_property_id>
GA_SERVICE_ACCOUNT_CREDENTIALS=<compressed_json_credentials>
- Universal Analytics: Admin > View Settings > View ID
- GA4: Admin > Property details > Property ID
Copy the contents of the service account JSON file and remove the white space so it fits on a single line. The end result should look like the following:
GA_SERVICE_ACCOUNT_CREDENTIALS={"type": "service_account", "project_id": "abc", ...}
Google Cloud:
Google Analytics:
- Adding a service account (Universal Analytics & GA4)
- Locating the view ID (Universal Analytics)
- Locating the property ID (GA4)
Universal Analytics:
GA4:
Universal Analytics & GA4:
For bugs or improvements please use the issues tab or email support@kyco.io.