Page feedback
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
Page feedback responses are collected in a Google Analytics report. It does not collect information about the people who submit feedback.
When and how to use it
When you install the page feedback component, it is automatically added to every page on your site.
Monitor the information you receive through page feedback so you know user sentiment and can catch problems early.
If you’re interested in using page feedback on your site, contact us through the Support page to get more information.
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-feedback data-endpoint-url="https://fa-go-feedback-001.azurewebsites.net/sendfeedback"></cagov-feedback>
Specs
Property | Value |
---|---|
Machine name | ds-feedback |
JavaScript | yes |
SCSS | ./src/css/index.scss |
Project installation
The instructions assume familiarity with npm package management tool, modern JavaScript techniques, and Sass.
npm i @cagov/[machine-name]
- Use
import
¹ orrequire
to include the component’s *JavaScript** in your page or compiler. - Include SCSS in your Sass compiler.
- Add the Sample markup to your HTML.
- Refer to the Content model section for notes on mapping your data to the Sample markup.
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
--primary-dark-color
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-color”:
:root {
--primary-color: #064e66;
}
Accessibility
Review items specific to the page feedback accessibility
- Make sure that add feedback
textarea
hasid
attribute that is referenced in its label’sfor
attribute. - Make sure that page feedback buttons and input fields have have solid, 2px outline that is using
—-highlight-color
variable on focused state.
Standard accessibility review
Components in Alpha status must pass the following accessibility reviews every time a new version is published:
- Tested with the
[axe](https://www.deque.com/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
Components in Beta status must pass the following accessibility reviews every time a new version is published:
- Tested with the
[axe](https://www.deque.com/axe/)
accessibility tool and passes all automated WCAG Level AA checks - Reviewed with the VoiceOver screen reader on desktop
- Reviewed with the TalkBack screen reader on mobile.
- 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
- Reviewed component display using content in English, Spanish, Simplified Chinese, German, and Arabic (using right to left display (RTL))
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.
Name | Attribute name | Data type | Field type | Description |
---|---|---|---|---|
Endpoint URL | data-endpoint-url | string | URL | Required field. Endpoint used to POST data if the user submits a comment. |
Question label | data-question | string | Plain text | Did you find what you were looking for? |
Yes label | data-yes | string | Plain text | Yes |
No label | data-no | string | Plain text | No |
Comment prompt | data-commentPrompt | string | Plain text | What was the problem? |
Positive comment prompt | data-positiveCommentPrompt | string | Plain text | Great! What were you looking for today? |
Thanks for feedback message | data-thanksFeedback | string | Plain text | Thank you for your feedback! |
Thanks for comments message | data-thanksComments | string | Plain text | Thank you for your comments! |
Submit button label | data-submit | string | Plain text | Submit |
Required field label | data-requiredField | string | Plain text | This field is required |
Comment prompt label | data-anythingToAdd | string | Plain text | If you have anything to add |
Additional feedback label | data-anyOtherFeedback | string | Plain text | If you have any other feedback about this website |
Values that this component will post:
Name | POST attribute name | Data type | Field type | Value |
---|---|---|---|---|
URL | url | string | URL | window.location.href |
If page was helpful | helpful | string | Plain text | this.wasHelpful |
Feedback comments | comments | string | Plain text | feedback.value |
User Agent | userAgent | string | Plain text | navigator.userAgent |