Client CraftClient Craft HubStart free

Add Client Craft to your layout

On this page
Updated 24 Nov 20261 min read

Step 3 of the full setup. One line in your layout turns on the cookie banner, analytics, forms and more.

Plan: All plans

Client Craft needs one line in your layout. From then on, what runs on your pages is decided in the workspace, not in code or in Content: turning on the cookie banner or website analytics later needs no new deployment.

Before you start #

  • The ClientCraft or ClientCraft.Core package is installed and appsettings are set. See Set up appsettings.json.
  • Website hosted by Client Craft? Skip this page: we set it up for you.

Step by step #

  1. 1
    Open your layoutOpen the layout view that your page templates share, usually Views/Shared/_Layout.cshtml or your site root's master template. If you have more than one layout, repeat these steps for each.
  2. 2
    Add the line first inside <head>
    html
    1<head>
    2 @await Html.ClientCraft().RenderAssets()
    3 <meta charset="utf-8" />
    4 ...
    5</head>

    Put it before other scripts. That way Client Craft's script protection can hold back tracking scripts until the visitor answers the cookie banner.

  3. 3
    Deploy and check a pageDeploy as usual and open a page of the site. Nothing visible changes until the site is connected (next step) and the workspace turns features on.

What the line turns on #

Everything the website's workspace has enabled for that page:

  • the cookie banner and script protection,
  • website analytics, heatmaps and session replays,
  • website forms sending to the CRM,
  • usage metering for your plan.

The page, website and language come from the request, so you add nothing per page. Rendering it twice is harmless: the second call outputs nothing.

TipFor internal tools that shouldn't show a cookie banner, use @await Html.ClientCraft().RenderAssets(banner: false). Forms and metering still run; features that need consent stay off.

What happens next #

Next step: Connect your site to Client Craft.

Was this article helpful?