Installing in Gatsby
Chord's Gatsby starter kit uses the ConsentManager React component. It comes with a fully built UI for selecting data collection preferences:

If you prefer to build a custom UI, you can use the ConsentManagerBuilder component. View the Github repo for complete installation instructions.
Installing the package
First, verify you have Segment's Analytics.js installed. Segment's npm package @segment/analytics-next is not currently compatible with the Consent Manager, so you'll need to install Segment via snippet.
Next, install the @segment/consent-manager package:
Configuring the Chord Gatsby theme
If you're using Chord's Gatsby theme, Segment loading is handled by the Gatsby Segment plugin. Set manualLoad to true in the segmentConfig object in your gatsby-config.js file, to allow the Consent Manager to handle loading:
If you're not using Chord's Gatsby theme, be sure to remove analytics.load("YOUR_WRITE_KEY") from your site code, so the Consent Manager can handle loading.
Adding the ConsentManager React component
Chord's Gatsby starter includes a ConsentManagerWrapper component. This component is responsible for configuring and rendering a banner (or pop-up, depending on your level of customization) that will offer users an option to opt in or out of tracking. To customize the look and behavior of the Consent Manager, change various properties on the ConsentManager component (full reference here).
Please note that the Consent Manager banner in the starter is shown automatically for visitors from the EU. Please refer to the shouldRequireConsent method of the component to alter that behavior. You can decide to show the banner for all visitors, regardless of their actual location, by configuring the GATSBY_SEGMENT_SHOULD_REQUIRE_CONSENT environment variable to true in your .env file.
The ConsentManagerWrapper component wraps the root page element of the starter in gatsby-browser.js. Here's a simplified example:
The starter also includes an example of a link that will open the Consent Manager pop-up.
Troubleshooting
I'm seeing a blank page.
If you customize the ConsentManagerWrapper component, make sure that the {children} prop coming from the wrapRootElement is placed before the <ConsentManager /> node:

If you accidentally changed that order, you might run into this known Gatsby issue, where a blank page is rendered all over the site. This issue only occurs with production builds, not development builds.
if you have any questions or need help, please reach out to us at help@chord.co