A project to publish website analytics for the US federal government.
For a detailed description of how the site works, read 18F's blog post on analytics.usa.gov.
Other organizations who have reused this project for their analytics dashboard:
- The City of Anchorage, AK
- The City of Boulder, CO
- The City of Los Angeles, CA
- The City of New Orleans, LA
- The City of Philadelphia, PA
- The City of Sacramento, CA
- The City of San Francisco, CA
- The City of Santa Monica, CA
- Cook County, IL
- Douglas County, NE
- Washington State University
- The States of Jersey
- Tennessee Department of Environment and Conservation
- U.S. Department of Education
- U.S. Department of Veterans Affairs
This blog post details their implementations and lessons learned.
Ths app uses Jekyll to build the site, and Sass, Bourbon, and Neat for CSS.
Install them all:
bundle installanalytics-reporter is the code that powers the analytics dashboard.
Please clone the analytics-reporter next to a local copy of this github repository.
- Ensure that data is being collected for a specific agency's Google Analytics ID. Visit 18F's analytics-reporter for more information. Save the url path for the data collection path.
- Create a new html file in the
_agenciesdirectory. The name of the file will be the url path.
touch _agencies/agencyx.html- Create a new html file in the
_data_pagesdirectory. Use the same name you used in step 2. This will be the data download page for this agency
touch _data_pages/agencyx.html- Set the required data for for the new files. (Both files need this data.) example:
---
name: Agency X # Name of the page
slug: agencyx # Same as the name of the html files. Used to generate data page links.
layout: default # type of layout used. available layouts are in `_layouts`
---- Agency page: Below the data you just entered, include the page content you want. The
_agenciespage will use thecharts.htmlpartial and the_data_pagespages will use thedata_download.htmlpartial. example:
{% include charts.html %}Run Jekyll with development settings:
make dev(This runs bundle exec jekyll serve --watch --config=_config.yml,_development.yml.)
The development settings assume data is available at /fakedata. You can change this in _development.yml.
If also working off of local data, e.g. using analytics-reporter, you will need to make the data available over HTTP and through CORS.
Various tools can do this. This project recommends using the Node module serve:
npm install -g serveGenerate data to a directory:
analytics --output [dir]
Then run serve from the output directory:
serve --corsThe data will be available at http://localhost:3000 over CORS, with no path prefix. For example, device data will be at http://localhost:3000/devices.json.
To deploy to analytics.usa.gov after building the site with the details in _config.yml:
make deploy_productionTo deploy to analytics-staging.app.cloud.gov after building the site with the details in _config.yml and _staging.yml:
make deploy_staging| Environment | Branch | URL |
|---|---|---|
| Production | master | https://analytics.usa.gov |
| Staging | master | https://analytics-staging.app.cloud.gov |
This project is in the worldwide public domain. As stated in CONTRIBUTING:
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.