browserslist-ga-export
allows you to generate a browserslist-stats.json
file for Google Analytics data using the Browserslist-GA parser without requiring you to log into a Google Account. Instead of logging into a Google Account, you must provide a CSV export of Google Analytics data.
npm install browserslist-ga-export --save-dev
Create a blank Exploration with the specifications listed below:
- Date range: Desired date range
- Dimensions:
- Operating system
- OS version
- Browser
- Browser version
- Device category
- Metrics: Views
- Rows (in this order):
- Operating system
- OS version
- Browser
- Browser version
- Device category
- Values: Views
Press the Export Data button and select the CSV option.
Use the browserslist-ga-export
CLI to generate a browserslist-stats.json
file based on the CSV file. See CLI documentation for more details.
browserslist-ga-export --reportPath {String} [options]
Ensure that language is set to "English (United States)" in user language settings. See #5 and #14 for an explanation of why this is necessary.
Create a custom report with the specifications listed below. You will be able to use this custom report for one or more desired Google Analytics view(s) associated with a Google Analytics account.
- Type: Flat Table
- Dimensions (in this order):
- Operating System
- Operating System Version
- Browser
- Browser Version
- Device Category
- Metrics: Pageviews
For each desired view, follow these steps to export the custom report as a CSV file:
- View the custom report.
- Sort the report by Browser column ascending alphabetically (arrow in column header facing up).
- Select the desired date range for the report.
- Show 5000 rows for the report.
- Export the report as a CSV file.
- If your report has more than 5,000 rows, you must export each page of the report individually.
Use the browserslist-ga-export CLI to generate a browserslist-stats.json
file based on the CSV file(s). See CLI documentation for more details.
browserslist-ga-export --reportPath {String} --firstRowIndex 7 [options]
Generate a browserslist-stats.json
file based on one or more Google Analytics data CSV files (see usage instructions).
Path or glob path pattern of CSV file(s) to process. If a glob path pattern is provided that resolves to multiple files, the browserslist-stats.json
file will represent the merged data of those files.
- Required
- Type: string
Zero-based index of first data row in CSV file. Default value is based on the default format of Google Analytics 4 CSV exports.
- Optional
- Type: number
- Default:
8
Output path for generated browserslist-stats.json
file. If a file already exists at the path, that file will be overwritten.
- Optional
- Type: string
- Default:
'browserslist-stats.json'
Generate browserslist-stats.json
from a Google Analytics 4 CSV file called browserslist-report.csv
:
browserslist-ga-export --reportPath browserslist-report.csv
Generate browserslist-stats.json
from a Universal Analytics CSV file called browserslist-report.csv
:
browserslist-ga-export --reportPath browserslist-report.csv --firstRowIndex 7
Generate browserslist-stats.json
from multiple CSV files in a folder called browserslist-reports
:
browserslist-ga-export -r browserslist-reports/*.csv
Generate custom usage data file called browser-stats.json
instead of browserslist-stats.json
:
browserslist-ga-export -r browserslist-report.csv -o browser-stats.json