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 government agencies who have reused this project for their analytics dashboard:
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- Set the required data for for the new file. example:
---
name: Agency X # Name of the page
data_url: https://analytics.usa.gov/data/agencyx # Data URL from step 1
layout: agencies # type of layout used. available layouts are in `_layouts`
---Run Jekyll with development settings:
make dev(This runs bundle exec jekyll serve --watch --config _.yml,_development.yml.)
Sass can watch the .scss source files for changes, and build the .css files automatically:
make watchTo compile the Sass stylesheets once, run make clean all, or make -B to compile even if the .css file already exists.
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.
Pushes to the 18f-pages branch are reflected in the staging environment https://pages.18f.gov/analytics.usa.gov/. All changes can be seen here prior to production release.
In production, the site's base URL is set to https://analytics.usa.gov and the data's base URL is set to https://analytics.usa.gov/data/live.
To deploy this app to analytics.usa.gov, you will need authorized access to 18F's Amazon S3 bucket for the project.
To deploy the site using s3cmd, production settings, and a 5 minute cache time, run:
make deployUse the full command above. The full command ensures that the build completes successfully, with production settings, before triggering an upload to the production bucket.
| Environment | Branch | URL |
|---|---|---|
| Staging | 18f-pages | https://pages.18f.gov/analytics.usa.gov/ |
| Production | 18f-pages | https://www.analytics.usa.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.