CSS HTML JavaScript Ruby Other
Clone or download
Failed to load latest commit information.
.circleci Update to CircleCI v2 Mar 20, 2018
_includes update text and link to repo (#513) Jul 6, 2018
_layouts Add a developer page to explain the API usage Apr 7, 2017
bin Add CircleCI in the right spot Mar 22, 2018
compliance Create component.yaml Dec 8, 2016
docs Swapping Gray for Tim as System Owner Jan 3, 2018
fake-data/live Finalize cloud.gov migration and restore data links (#408) Nov 29, 2016
js lower display threshold for Windows versions from 1% to 0.1% (#514) Jul 9, 2018
sass added location data, minor visualization bug still needs to be fixed Oct 16, 2015
.about.yml adding more info Oct 17, 2016
.dockerignore Update production Docker image to use custom nginx config May 3, 2017
.gitignore dockerization Apr 18, 2017
404.html Finalize cloud.gov migration and restore data links (#408) Nov 29, 2016
CONTRIBUTING.md remove the 18F-specific language Jan 14, 2015
Dockerfile code review Apr 21, 2017
Dockerfile.production Update production Docker image to use custom nginx config May 3, 2017
Gemfile Add versions to gems in Gemfile Jun 27, 2017
Gemfile.lock Add versions to gems in Gemfile Jun 27, 2017
LICENSE.md list exceptions to license, linking to their licenses Jan 26, 2015
Makefile Update production Docker image to use custom nginx config May 3, 2017
README.md Fix environemnt typo Sep 7, 2017
Staticfile Deploying to cloud gov (#404) Nov 17, 2016
_config.yml Removing shutdown banner Jan 23, 2018
_staging.yml Finalize cloud.gov migration and restore data links (#408) Nov 29, 2016
data.html move variables into includes so they don't have to be declared in new… Jun 3, 2016
docker-compose.yml fix make command Apr 21, 2017
index.html move charts to include and refactor layouts to use that May 26, 2016
manifest.yml Finalize cloud.gov migration and restore data links (#408) Nov 29, 2016
system-security-plan.yml changing link Apr 19, 2017


Code Climate CircleCI Dependency Status


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 Town of Apex, NC
The City of Boulder, CO The City of Chesapeake, VA
The City of Concord, NC The City of Eagle Mountain, UT
The City of Evanston, IL The City of Los Angeles, CA
The City of New Orleans, LA The City of Newark, NJ
The Borough of Norristown, PA The City of Omaha, NE
The City of Philadelphia, PA The City of Pleasanton, CA
The City of Princeton, NJ The City of Sacramento, CA
The City of San Francisco, CA The City of San Leandro, CA
The City of Santa Monica, CA Carbarrus County, NC
Cook County, IL data.jerseycitynj.gov
data.seattle.gov Douglas County, NE
Moulton Niguel Water District NYSERDA
Washington State University Rowan County, NC
The States of Jersey Tennessee Dept of Environment and Conservation
U.S. Department of Education U.S. Department of Veterans Affairs

This blog post details their implementations and lessons learned.

Setup using Docker

You need Docker and docker-compose.

To build and run the app with docker-compose, run docker-compose up -d then you can access the app from http://localhost:4000, as the local filesystem is mounted on top of the docker container you can edit the files as you are developing locally.

To see the jekyll logs, run:

docker-compose logs -f

Setup using Ruby

Ths app uses Jekyll to build the site, and Sass, Bourbon, and Neat for CSS.

Install them all:

bundle install

analytics-reporter is the code that powers the analytics dashboard. Please clone the analytics-reporter next to a local copy of this github repository.

Adding Additional Agencies

  1. 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.
  2. Create a new html file in the _agencies directory. The name of the file will be the url path.
touch _agencies/agencyx.html
  1. Create a new html file in the _data_pages directory. Use the same name you used in step 2. This will be the data download page for this agency
touch _data_pages/agencyx.html
  1. 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`
  1. Agency page: Below the data you just entered, include the page content you want. The _agencies page will use the charts.html partial and the _data_pages pages will use the data_download.html partial. example:
{% include charts.html %}

Developing locally

Run Jekyll with development settings:

make dev

(This runs bundle exec jekyll serve --watch --config=_config.yml,_development.yml.)

Developing with local data

The development settings assume data is available at /fakedata. You can change this in _development.yml.

Developing with real live data from analytics-reporter

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 serve

Generate data to a directory:

analytics --output [dir]

Then run serve from the output directory:

serve --cors

The 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.

Deploying the app

To deploy to analytics.usa.gov after building the site with the details in _config.yml:

make deploy_production

To deploy to analytics-staging.app.cloud.gov after building the site with the details in _config.yml and _staging.yml:

make deploy_staging

Deploying the app using Docker

NOTE: 18F does not use Docker in production!

If you are using Docker in production and you want to deploy just the static pages, you can build an nginx container with the static files built in, running the following command:

make docker-build-production PROD_IMAGE=yourvendor/your-image-name PROD_TAG=production

The resulting image will be an nginx server image that you can safely push and deploy to your server.

The image accepts an environment variable to specify the S3 URL that data at /data/* is served from:

docker run -p 8080:80 -e S3_BUCKET_URL=https://s3-us-gov-west-1.amazonaws.com/your-s3-bucket/data yourvendor/your-image-name:production

Building & Pushing Docker Images

This repo has git tags. The tag for Docker images built for this repo relate to these git tags. In the examples below, <version refers to the tag value of the current commit. When building a new version, be sure to increment the git tag appropriately.

When building images there are 2 images to build: <version> and <version>-production.

To build the images:

docker build -f ./Dockerfile -t 18fgsa/analytics.usa.gov:<version> .
docker build -f ./Dockerfile.production -t 18fgsa/analytics.usa.gov:<version>-production .

To push the images:

docker push 18fgsa/analytics.usa.gov:<version>
docker push 18fgsa/analytics.usa.gov:<version>-production


Environment Branch URL
Production master https://analytics.usa.gov
Staging master https://analytics-staging.app.cloud.gov

Public domain

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.