browserslist-ga-export
Overview
Generate browserslist-stats.json
using Browserslist-GA without logging into a Google Account.
browserslist-ga-export allows you to generate the same Browserslist custom usage data file 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. This tool also allows you to generate a custom usage data file representing the merged data of multiple CSV files.
Installation
npm install browserslist-ga-export --save-dev
Usage
1) Check user language setting
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.
2) Create custom report
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
3) Export custom report CSV file(s)
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.
4) Generate custom usage data file based on CSV file(s)
Use the browserslist-ga-export CLI to generate a custom usage data file based on the CSV file(s). See CLI documentation for more details.
browserslist-ga-export --reportPath {String} [options]
CLI
browserslist-ga-export
Create a custom usage data JSON file based on one or more Google Analytics custom report CSV files (see usage instructions).
Options
--reportPath
(-r
)
Path or glob path pattern of report CSV file(s) to process. If a glob path pattern is provided that resolves to multiple files, the custom usage data file will represent the merged data of those files.
- Required
- Type: string
--ignoreRows
(-i
)
Number of rows at beginning of report CSV file(s) to exclude from processing. Default value is based on the default format of Google Analytics custom report CSV exports.
- Optional
- Type: number
- Default:
7
--outputPath
(-o
)
Output path for generated custom usage data file. If a file already exists at --outputPath
, that file will be overwritten.
- Optional
- Type: string
- Default:
'browserslist-stats.json'
Examples
browserslist-ga-export --reportPath browserslist-report.csv
browserslist-ga-export -r browserslist-reports/*.csv
browserslist-ga-export -r browser-report.csv -o browser-stats.json
browserslist-ga-export -r browser-report.csv -i 0