browserslist-ga-export
Generate browserslist-stats.json
using Browserslist-GA without logging into a Google Account.
browserslist-ga-export allows you to generate the same browserslist-stats.json
that Browserslist-GA would generate for a Google Analytics view without requiring you to log into a Google Account. Instead of logging into a Google Account, you must provide a CSV export of a Google Analytics custom report.
Installation
If you are using npm:
$ npm install --save-dev browserslist-ga-export
If you are using Yarn:
$ yarn add --dev browserslist-ga-export
Usage
1) Export custom report as CSV
- Create a custom report for the desired Google Analytics view using the format below (the language you see in Google Analytics may vary depending on your user language settings):
- Type: Flat Table
- Dimensions (in this order):
- Operating System
- Operating System Version
- Browser
- Browser Version
- Device Category
- Metrics: Pageviews or Page Views
- View the 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.
2) Convert CSV into browserslist-stats.json
If you are using npm v5.2.0 or higher:
$ npx browserslist-ga-export --reportPath {path-to-export}.csv
If you are using Yarn:
$ yarn browserslist-ga-export --reportPath {path-to-export}.csv
You can also add a script to package.json, for example:
"scripts": {
"update-browserslist-stats": "browserslist-ga-export --reportPath {path-to-export}.csv"
}
CLI Options
Name | Type | Default | Description |
---|
ignoreRows | {Number} | 7 | Number of rows at beginning of CSV file to exclude from data passed to Browserslist-GA. The default value is based on the default format of Google Analytics custom report CSV exports. |
outputPath | {String} | 'browserslist-stats.json' | Path for exported browserslist-stats file. |
reportPath | {String} | null | Path of report CSV to process. |