Features Pricing Docs Security FAQ Log in EN PL
← Back to guides
J
JAMstack

Gatsby / Static generator

Difficulty: Easy Setup time: 3 min

Plugin gatsby-plugin-html in gatsby-ssr.js using onRenderBody.

01

Add snippet in gatsby-ssr.js

In gatsby-ssr.js (create it if missing). The first component is the inline Consent Mode stub, the second the loader:

exports.onRenderBody = ({ setHeadComponents }) => {
  setHeadComponents([
    <script
      key="consentlane-stub"
      dangerouslySetInnerHTML={{ __html: `
window.dataLayer=window.dataLayer||[];window.gtag=window.gtag||function(){window.dataLayer.push(arguments)};
gtag('consent','default',{ad_storage:'denied',ad_user_data:'denied',ad_personalization:'denied',analytics_storage:'denied',wait_for_update:500});
window.uetq=window.uetq||[];window.uetq.push('consent','default',{ad_storage:'denied'});
      ` }}
    />,
    <script
      key="consentlane"
      async
      src="https://consentlane.com/v1/cl.js?s=YOUR_KEY"
    />,
  ])
}
02

Build and deploy

gatsby build → the snippet will be embedded in every generated HTML page.

Ready to try? The Free plan is enough to start.

Sign up