Skip to content

Page feedback

Readme Changelog

Development stage

In research

Alpha components have not been thoroughly tested by developers. Learn more about component maturity.

The page feedback component lets people react to specific pages on your website. It puts the question, "Did you find this page useful?" above the department footer on every page. It has buttons to reply Yes or No, followed by a comment field.

The page feedback component is intended to:

  • Let people point out bugs or out-of-date content
  • Inform iterations to content pages
  • Determine hierarchy and priority of information
  • Identify themes in user sentiment
  • Pinpoint missing or confusing content
  • Identify specific spikes in feedback related to events

When and how to use it

We're still working on training and data services that supports the page feedback component. If you're interested in using page feedback, reach out through our Contact us page. We'd like to hear more about your needs as we work on these services.

How not to use it

Do not use the page feedback component on pages that are part of a transactional process flow. This can distract people from finishing their task.

Demo and sample markup


<cagov-page-feedback data-endpoint-url=""></cagov-page-feedback>

Optional parameters

  • data-endpoint-url

This can be defined if you wanted to supply your own data collection endpoint. This is not necessary and most implementations can omit this and take advantage of the default endpoint hosted by ODI at The code will hit this endpoint if this parameter is not used.


Machine nameds-feedback

Project installation

The instructions assume familiarity with npm package management tool, modern JavaScript techniques, and Sass.

  1. npm i @cagov/ds-page-feedback
  2. Use import¹ or require to include the component’s JavaScript in your page or compiler.
  3. Add the sample markup to your HTML.
  4. Refer to the Content model section for notes on mapping your data to the sample markup.

CDN installation

We recommend using a build system and bundling your JavaScript for faster performance. If you do not use a build system, you can include the code from our CDN with a script tag.


<script type="module" src=""></script>

Other information

  • The page feedback component requires the data-endpoint-url="" attribute for the endpoint to POST data to if the user submits a comment.
  • The component also accepts optional text strings to support multiple languages.
  • If you use the endpoint from the markup, data will be collected in a central Office of Digital Innovation (ODI) database and can be retrieved via API or Google Data Studio dashboard.
  • The endpoint URL for any state website is supplied by ODI and can be obtained upon request.
  • If you want to use this frontend component with your own backend service you can supply your own endpoint and the page feedback web component will POST the following fields on submit: comment, helpful, url, userAgent
  • The component will send Google Analytics events when the initial Yes/No buttons are clicked and will submit the full form response including the comment, whether they clicked that the page was helpful or not and their user agent.

CSS variables

The following CSS variables are used in this component:

  • --w-lg
  • --s-1
  • --s-2
  • --border-1
  • --border-2
  • --radius-2
  • --font-size-2
  • --font-weight-6
  • --font-lineheight-3
  • --white
  • --gray-200
  • --accent2-500
  • --primary-900

All CSS variables define their own fallback value so you do not have to use additional CSS unless you want to change them. You may define your own value for the variable by adding your own style rules. Here is an example defining the global hex value for a CSS variable named “--primary-700”:


:root {
  --primary-700: #165ac2;


Component-specific accessibility review

  • Make sure that add feedback textarea has id attribute that is referenced in its label’s for attribute.
  • Make sure that page feedback buttons and input fields have solid, 2px outline that uses --accent2-500 variable on focused state.

Standard accessibility review

As a component in Alpha status, this component must pass the following accessibility reviews every time a new version is published:

  • Tested with the axe accessibility tool and passes all automated WCAG Level AA checks
  • Reviewed with the VoiceOver screen reader on desktop
  • Verified keyboard navigation and that all actionable elements of the component are reachable via keyboard commands only
  • Reviewed component layout on a variety of screen sizes

Progressive enhancement

This component uses a custom element defined in JavaScript in addition to HTML and CSS. Edge, Firefox, Safari, and Chrome support custom elements. If the JavaScript for this component is not delivered or supported, the component will not display. This is the desired behavior because this component is not critical for site interaction. It uses CSS variables to inherit design token values. Token definitions are not required because these style rules provide fallback values.

Content model

This component uses the following data attributes. We provide this information to help with integrating the component into backend publishing systems or identifying content that may require translation.

NameAttribute nameData typeField typeDescription
Endpoint URLdata-endpoint-urlstringURLRequired field. Endpoint used to POST data if the user submits a comment.
Question labeldata-questionstringPlain textDid you find what you were looking for?
Yes labeldata-yesstringPlain textYes
No labeldata-nostringPlain textNo
Comment promptdata-commentPromptstringPlain textWhat was the problem?
Positive comment promptdata-positiveCommentPromptstringPlain textGreat! What were you looking for today?
Thanks for feedback messagedata-thanksFeedbackstringPlain textThank you for your feedback!
Thanks for comments messagedata-thanksCommentsstringPlain textThank you for your comments!
Submit button labeldata-submitstringPlain textSubmit
Required field labeldata-requiredFieldstringPlain textThis field is required
Comment prompt labeldata-anythingToAddstringPlain textIf you have anything to add
Additional feedback labeldata-anyOtherFeedbackstringPlain textIf you have any other feedback about this website

Values that this component will post:

NamePOST attribute nameData typeField typeValue
If page was helpfulhelpfulstringPlain textthis.wasHelpful
Feedback commentscommentsstringPlain textfeedback.value
User AgentuserAgentstringPlain textnavigator.userAgent

Contributor/developer documentation