Fetches structured pageview data from Google Analytics, primarily used with guess.js for predictive prefetching. Current version 0.4.20 releases infrequently. Key differentiator: it pulls GA data for ML-driven route prediction, not just reporting. Requires service account credentials and GA view ID. Deprecated in favor of guess-ga in the guess-js organization.
npm install guess-gaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates fetching Google Analytics pageview data with JWT authentication and route list.
Migrate to @guess-js/ga or use the official Google Analytics Data API directly.
Ensure period.startDate and period.endDate are Date instances and routes is an array of route paths.
Add the service account email as a user in GA with 'Read & Analyze' permissions.
Enable the 'Google Analytics Reporting API' in the Google Cloud Console for the project.
Create a new service account for each Google Analytics account and download separate credentials.
Ensure credentials.json contains 'client_email' and 'private_key' properties.
Add the service account email as a user in GA with 'Read & Analyze' permissions.
Convert startDate and endDate to Date instances before passing to fetch.
Provide at least one route string in the routes array.