Next.js Integration Guide

Welcome to our guide on integrating Concord into a Next.js application. We make it easy to integrate Concord into your Next.js applications in just a few minutes and this guide will help you get up and running quickly. This guide includes the following information:

  • Initial Concord configuration.
  • Google Consent Mode V2 configuration.
  • Integrating Concord into a Next.js application.

Getting Started With Concord

As part of the initial onboarding process that occurs when you set up a new organization or project in Concord, you will be able to choose your preferred consent settings, including the Consent Mode (Implied vs. Express), the Blocking mode (how trackers like cookies, scripts, iframes, etc. are processed and blocked), the Google Consent Mode V2 setting (we recommend Basic mode for most companies), the Consent Duration (how long consent lasts), and other options (Sensitive Information consent, Do Not Sell, Global Privacy Control, etc.).

During that process, we provide sensible defaults that are recommended as the default global settings, but those settings can always be adjusted and additional regions can also be added and customized later in all paid plans.

For more details on this process or to complete it for the first time, please follow the instructions in this guide: https://www.concord.tech/docs/getting-started

Our Google Consent Mode V2 integration allows websites to adjust how and when data is shared with Google based on user consent collected via the Concord Consent Banner & Privacy Center. To learn more about Google Consent Mode V2 and the recommended settings, please refer to this document: https://www.concord.tech/docs/understanding-configuring-google-consent-mode-gcm-v2

Integrating Concord Into a Next.js Application

The final step is to Integrate Concord into your Next.js application, which typically takes just a few minutes. Please follow the instructions below to complete this part of the process using the latest version of Next.js and the app router:

1. Login to your Concord organization and go to Deployment → Integrations → Install Concord and locate and copy the Project ID for the project you want to add to your Next.js application (projects can be changed via the Projects selector in the page header if needed).

2. In your Next.js application open your layout.tsx/layout.js file. In this example, we have created a standard Next.js application via Create Next App so the file is in the root of the app folder.

3. If, not imported yet, import Script from next/script:

import Script from "next/script";

4. Use the Project ID you copied above to add a script that uses the beforeInteractive strategy directive.

      <Script
        src="https://api.concord.tech/site-v1/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/site-client"
        strategy="beforeInteractive"
      />
  • Note: make sure you are using your Project ID instead of XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX in the src portion of the script.

5. Deploy your application and ensure that the Concord script tag shows up in the source code above other scripts.

6. Go back to Concord to verify your integration under Deployment → Integrations → Install Concord. If successfully added and deployed, you should see the following:

Congratulations. You have successfully integrated Concord into your Next.js application and any future changes to your attached project in Concord will be automatically synced to your application.