# Cookie Consent for the Surface Tag





Surface does not show its own cookie banner. It follows the one on your site. Forms still load and accept submissions whatever the visitor chooses.

## Set It Up [#set-it-up]

<Steps>
  <Step title="Turn on consent mode in the Surface Tag">
    Add `data-consent-mode` to your existing [Surface Tag](https://www.withsurface.com/docs/platform/traffic/surface-tag). The tag then tracks nobody until your banner says yes.

    ```html
    <script
      src="https://cdn.jsdelivr.net/gh/trysurface/scripts@latest/surface_tag.min.js"
      site-id="YOUR_SITE_ID"
      data-consent-mode>
    </script>
    ```
  </Step>

  <Step title="Send the visitor's choice to Surface">
    Call this from your banner on every page load and whenever the visitor changes their choice, including when they reject.

    ```js
    window.SurfaceSetConsent({
      adTracking: marketingAccepted === true,       // Ad & Conversion Tracking
      surfaceAnalytics: analyticsAccepted === true, // Surface Analytics
      cookieTracking: cookiesAccepted === true      // Cookie Tracking
    });
    ```

    Send all three every time. Anything not `true` counts as a no.
  </Step>
</Steps>

## What the Settings Mean [#what-the-settings-mean]

Each form's **Privacy** settings decide how it treats these three categories:

<Frame caption="Form Settings → Privacy: pick Always, On consent or Never for each category.">
    <img alt="The form Privacy settings" src="__img0" />
</Frame>

| Setting        | What happens                                 |
| -------------- | -------------------------------------------- |
| **Always**     | Tracks every visitor, whatever they choose.  |
| **On consent** | Follows the visitor's choice in your banner. |
| **Never**      | Never tracks.                                |

Before a visitor chooses, **On consent** holds off in the EU, EEA and UK (or when location is unknown) and tracks everyone else. To hold off everywhere, send all `false` until the visitor accepts.

## Developer Details [#developer-details]

<Accordion title="If the tag loads async or through a tag manager">
  Put this above the tag and your banner code, so calls made before the tag loads are queued and replayed:

  ```html
  <script>
    window.SurfaceTagQueue = window.SurfaceTagQueue || [];
    window.SurfaceSetConsent = window.SurfaceSetConsent || function (consent) {
      window.SurfaceTagQueue.push({ type: "consent", args: [consent] });
    };
  </script>
  ```
</Accordion>

<Accordion title="Test it">
  In a private window on your live site:

  1. **Before accepting:** no `surface_journey_id` or `surface_recent_visit` cookies, and no `surfaceLeadData` in local storage.
  2. **Accept:** tracking starts.
  3. **Withdraw:** those cookies and the stored data are cleared.
  4. **Submit a form with tracking denied:** the response and workflows still work.
</Accordion>
