{"id":18697375,"url":"https://github.com/allanreda/ga4-session-predictor-flask-app","last_synced_at":"2026-05-03T20:34:29.964Z","repository":{"id":237788334,"uuid":"792227646","full_name":"allanreda/GA4-Session-Predictor-Flask-App","owner":"allanreda","description":"Flask app that can predict future number of GA4 sessions, using the Prophet library.","archived":false,"fork":false,"pushed_at":"2025-01-08T20:12:04.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-23T23:36:10.368Z","etag":null,"topics":["data-visualization","flask","ga4-api","matplotlib","pandas","prophet-library","python","time-series-forecasting"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allanreda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-26T08:31:12.000Z","updated_at":"2025-01-08T20:12:07.000Z","dependencies_parsed_at":"2025-05-19T01:09:40.401Z","dependency_job_id":"761984d1-a838-4182-a653-ae89cf739867","html_url":"https://github.com/allanreda/GA4-Session-Predictor-Flask-App","commit_stats":null,"previous_names":["allanreda/ga4-session-predictor-flask-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/allanreda/GA4-Session-Predictor-Flask-App","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allanreda%2FGA4-Session-Predictor-Flask-App","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allanreda%2FGA4-Session-Predictor-Flask-App/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allanreda%2FGA4-Session-Predictor-Flask-App/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allanreda%2FGA4-Session-Predictor-Flask-App/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allanreda","download_url":"https://codeload.github.com/allanreda/GA4-Session-Predictor-Flask-App/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allanreda%2FGA4-Session-Predictor-Flask-App/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32584137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-visualization","flask","ga4-api","matplotlib","pandas","prophet-library","python","time-series-forecasting"],"created_at":"2024-11-07T11:24:05.214Z","updated_at":"2026-05-03T20:34:28.429Z","avatar_url":"https://github.com/allanreda.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GA4 Session Predictor\r\n\r\nhttps://github.com/user-attachments/assets/45758ce1-fea8-4119-858a-56f9a88849d2  \r\n\r\n## Overview\r\nThis repository firstly, contains a standalone script for testing local app functionalities, model parameter adjustment and model validation. This script also allows for visualizing forecasts and seasonality/holiday effects. Secondly, this repository contains both the backend and frontend for a Flask app that can predict the number of daily website sessions measured in GA4, based on historical data. The idea behind the setup of the repository being that one can adjust and test the model parameters, until it performs at a satisfactory level on the data of the desired GA4 property. The model can then be applied in the backend of the Flask app, which ultimately provides a solid tool for predicting your daily GA4 sessions.\r\n\r\n## Functionality\r\n\r\n### functionalities.py:\r\nThis script contains the foundation of the functionalities in the backend of the Flask app, thus the name of the script. It contains the functions that lists all available GA4 accounts and properties to the logged in user, and the function that pulls all the daily sessions of the last two years (if available).   \r\nMost important of all, it contains the model itself with all of its parameters, which provides the opportunity to experiment and add new ones or remove existing ones. The model is also trained on all Danish holidays/vacations, which can also be added/removed.   \r\n\u003cpre lang=\"no-highlight\"\u003e\u003ccode\u003e\r\n# Initialize the Prophet model\r\nmodel = Prophet(growth = 'logistic',\r\n                holidays=all_holidays_df, # Include holidays in the model\r\n                changepoint_prior_scale = 0.01,\r\n                holidays_prior_scale = 5,\r\n                daily_seasonality = True)\r\n\u003c/code\u003e\u003c/pre\u003e\r\nThe forecasts of the model can then be visualized, together with its seasonality/holiday effects.  \r\n\r\n#### Example of plotted historical and forecasted daily sessions:  \r\n![image](https://github.com/user-attachments/assets/abf4e0f1-36ed-467d-a53d-99f43468fb19)  \r\n  \r\n#### Example of plotted forecasted daily sessions only:  \r\n![image](https://github.com/user-attachments/assets/add48a6c-8c2c-43df-8fd1-93102a09859d)  \r\n\r\n#### Example of plotted holiday effects:  \r\n![image](https://github.com/user-attachments/assets/ed46beb7-7b6b-47a0-a5b4-980969319f41)   \r\n\r\n#### Example of plotted seasonality effects:  \r\n![image](https://github.com/user-attachments/assets/2cdab991-350b-459a-a813-22b99c6fc987)  \r\n\r\n#### Example of plotted weekly effects:  \r\n![image](https://github.com/user-attachments/assets/b2cfbb44-5fc2-4ee8-8dc1-9f72f37ac089)  \r\n  \r\n#### Example of plotted average model performance metrics  \r\n\r\nLastly, the script contains a section for cross validation, which can be adjusted as needed. This section calculates the average evaluation metrics 'mse', 'rmse', 'mae', 'mape' and also allows for the visualization of those.  \r\n\r\n\u003ctable\u003e\r\n  \u003ctr\u003e\r\n    \u003ctd\u003e\u003cimg src=\"https://github.com/user-attachments/assets/7dfe419a-4da1-431f-b279-6668995156d0\" alt=\"Image 1\" width=\"300\"/\u003e\u003c/td\u003e\r\n    \u003ctd\u003e\u003cimg src=\"https://github.com/user-attachments/assets/a54c9033-debe-4551-b763-eba667dc3137\" alt=\"Image 2\" width=\"300\"/\u003e\u003c/td\u003e\r\n  \u003c/tr\u003e\r\n  \u003ctr\u003e\r\n    \u003ctd\u003e\u003cimg src=\"https://github.com/user-attachments/assets/3c9a13ca-d3d9-4a20-a337-576292f7f7f3\" alt=\"Image 3\" width=\"300\"/\u003e\u003c/td\u003e\r\n    \u003ctd\u003e\u003cimg src=\"https://github.com/user-attachments/assets/1b18bc15-051f-43c9-9a43-7906d2d412af\" alt=\"Image 4\" width=\"300\"/\u003e\u003c/td\u003e\r\n  \u003c/tr\u003e\r\n\u003c/table\u003e\r\n\r\n### local_deployment (folder for the Flask app script)\r\nThe folder contains both the backend of the Flask app, in the form of the app.py file, and the frontend the app, in the form of the three templates in the \"templates\" folder.  \r\nAll together they make up the three components that makes up the app itself.  \r\nThe first part is the login which activates the OAuth flow which allows for the user to log in to the Google account that has access to the desired GA4 account(s).  \r\nThe second part is where the user gets to choose the desired GA4 account and property, from which the historical sessions will be pulled.  \r\nThe third and most important part, is where the user will see the historical daily sessions displayed on the left chart and have the opportunity to choose a number of days to forecast. The forecasted daily sessions will then be displayed in the right chart.\r\n\r\n## Technologies  \r\nThe project is built using:  \r\n-Flask for building and interactive interface  \r\n-The Google Analytics Admin API (v1alpha) for accessing available GA4 accounts and properties  \r\n-The Google Analytics 4 API for pulling historical number of daily sessions  \r\n-Prophet for model creation, time series forecasting and cross validation  \r\n-Matplotlib for visualisation  \r\n-Pandas for data manipulation\r\n\r\n## Goal\r\nThe aim of this project is to empower Danish GA4 users and website owners to forecast daily session counts and understand the impact of seasons, holidays, and vacations on web traffic. The project provides a user-friendly interface that can be deployed locally and used to anticipate future traffic. Additionally, it offers a straightforward method for comprehending historical web traffic patterns and their determinants.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallanreda%2Fga4-session-predictor-flask-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallanreda%2Fga4-session-predictor-flask-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallanreda%2Fga4-session-predictor-flask-app/lists"}