블로그로 돌아가기
Technical

Umbraco Cookie Consent: NuGet Package for .NET Developers

GetCookies 팀January 13, 202513분 소요
Umbraco.NETNuGetCMSIntegration

TLDR: GetCookies for Umbraco is a NuGet package for .NET 6/7/8 that adds GDPR-compliant consent management to Umbraco 10-13. One package install, three lines of config, and your Umbraco site has IAB TCF 2.2, Google Consent Mode v2, and a backoffice dashboard.

Read full summary

Complete guide to implementing cookie consent on Umbraco CMS using the GetCookies NuGet package. Covers installation, configuration, Tag Helpers, script blocking, and the Umbraco backoffice integration for viewing consent analytics and scan results—all compliant with GDPR, CCPA, and other privacy regulations.

Summary by Claude AI

The .NET Developer's Compliance Challenge

Illustrative scenario: a composite example, not a specific reported case.

A government agency in the Netherlands was running 23 public websites on Umbraco. When the Dutch DPA announced stricter enforcement of cookie consent requirements, their development team faced a problem: most cookie consent solutions were built for WordPress or JavaScript-first stacks.

The available options required extensive custom integration, didn't follow .NET conventions, and lacked proper NuGet packaging. Their team spent three months building a custom solution—only to discover it didn't support the new Google Consent Mode v2 requirements.

Umbraco developers deserve a consent solution built for .NET, not adapted from WordPress plugins.

Why Umbraco Needs Native Consent Management

Umbraco powers enterprise websites, government portals, and high-traffic applications. These sites have specific requirements:

  • .NET ecosystem integration: DI, configuration, middleware patterns
  • Backoffice administration: Content editors need to manage settings without developer involvement
  • Multi-site deployments: Many Umbraco installations host multiple domains
  • Performance requirements: Enterprise sites can't afford blocking JavaScript loads

Generic JavaScript-only consent tools create friction. A native NuGet package integrates properly.

GetCookies for Umbraco

The GetCookies Umbraco package provides full consent management built for .NET developers:

Key Features

Feature Description
NuGet Installation Standard .NET package management
Umbraco 10-13 Support Works with current LTS and latest versions
.NET 6/7/8 Full modern .NET support
IAB TCF 2.2 Certified for programmatic advertising
Google Consent Mode v2 Native integration with proper signal timing
Backoffice Dashboard Consent analytics in Umbraco admin
Tag Helpers Razor-native components

Installation

Via .NET CLI

dotnet add package GetCookie.Umbraco

Via Package Manager Console

Install-Package GetCookie.Umbraco

Via NuGet Package Manager

Search for "GetCookie.Umbraco" in Visual Studio's NuGet Package Manager.

Configuration

Step 1: Add Settings to appsettings.json

{
  "GetCookie": {
    "DomainId": "your-domain-id",
    "ApiKey": "your-api-key",
    "ApiUrl": "https://getcookies.co"
  }
}

Get your Domain ID and API key from your GetCookies Dashboard.

Step 2: Register Services

In your Program.cs:

using GetCookie.Umbraco;

var builder = WebApplication.CreateBuilder(args);

// Add GetCookie services
builder.Services.AddGetCookie(builder.Configuration);

// Add to Umbraco pipeline
builder.CreateUmbracoBuilder()
    .AddBackOffice()
    .AddWebsite()
    .AddGetCookieIntegration()  // GetCookie integration
    .Build();

var app = builder.Build();

Step 3: Add to Layout

In your _Layout.cshtml:

@using GetCookie.Umbraco

<!DOCTYPE html>
<html>
<head>
    @* GetCookie head scripts (consent defaults, early initialization) *@
    @await Html.PartialAsync("_GetCookieHead")

    <!-- Your other head content -->
</head>
<body>
    @RenderBody()

    @* GetCookie widget (banner, privacy trigger) *@
    @await Html.PartialAsync("_GetCookieWidget")
</body>
</html>

That's it. Your site now has compliant cookie consent.

Using Tag Helpers

The package includes Razor Tag Helpers for cleaner markup:

Cookie Declaration

Add a cookie declaration to your privacy policy page:

<get-cookie-declaration language="en" />

This renders an auto-updating list of all cookies detected on your site.

Script Blocking

Mark scripts that should only load after consent:

@* Analytics scripts - blocked until analytics consent *@
<script type="text/plain" data-olc-category="analytics">
    gtag('config', 'GA_TRACKING_ID');
</script>

@* Marketing scripts - blocked until marketing consent *@
<script type="text/plain" data-olc-category="marketing">
    fbq('init', 'PIXEL_ID');
</script>

The type="text/plain" prevents execution. GetCookie activates the scripts when the user consents to the specified category.

Conditional Rendering

Use the consent service in Razor:

@inject IGetCookieService CookieService

@if (await CookieService.HasConsentAsync("analytics"))
{
    <script src="~/scripts/analytics.js"></script>
}

Umbraco Backoffice Integration

The package adds a "GetCookie" section to the Umbraco backoffice:

Dashboard Tab

View consent analytics directly in Umbraco:

  • Daily consent rate trends
  • Category breakdown (what users accept/reject)
  • Geographic distribution
  • Device type analysis

Settings Tab

Configure consent behavior without deploying code:

  • Banner style selection
  • Category customization
  • Region-specific rules
  • Language settings

Scan Results Tab

Review cookies detected on your site:

  • Cookie inventory with sources
  • Classification status
  • Compliance warnings
  • Missing cookies alerts

Cookie Declaration Preview

See exactly what your privacy policy will display:

  • Cookie list by category
  • Duration and purpose
  • Provider information
  • Declaration history

Multi-Site Configuration

For Umbraco installations hosting multiple domains, configure per-domain settings:

{
  "GetCookie": {
    "Domains": {
      "example.com": {
        "DomainId": "domain-id-1",
        "ApiKey": "api-key-1"
      },
      "example.de": {
        "DomainId": "domain-id-2",
        "ApiKey": "api-key-2"
      }
    }
  }
}

The package automatically selects the correct configuration based on the request host.

Google Consent Mode v2 Integration

GetCookie handles Google Consent Mode automatically:

// This happens automatically in _GetCookieHead partial:

// 1. dataLayer initialized
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

// 2. Consent defaults set BEFORE Google tags
gtag('consent', 'default', {
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'analytics_storage': 'denied',
  'wait_for_update': 500
});

// 3. After user consent, signals are updated
gtag('consent', 'update', {
  'analytics_storage': 'granted'
  // ... other categories based on user choice
});

Your Google Analytics and Google Ads tags receive proper consent signals with correct timing.

Microsoft UET Consent Mode

For sites using Microsoft Advertising (Bing Ads), GetCookie also supports UET Consent Mode:

// Automatic integration:
window.uetq = window.uetq || [];
window.uetq.push('consent', 'default', {
  'ad_storage': 'denied'
});

// After marketing consent:
window.uetq.push('consent', 'update', {
  'ad_storage': 'granted'
});

Common Integration Patterns

With Umbraco Commerce

Block e-commerce tracking until consent:

<script type="text/plain" data-olc-category="analytics">
    // Umbraco Commerce tracking
    uCommerceAnalytics.trackPageView();
</script>

With Examine Search

If you're tracking search analytics:

public class SearchController : SurfaceController
{
    private readonly IGetCookieService _cookieService;

    public async Task<IActionResult> Search(string query)
    {
        // Only track search analytics if consent given
        if (await _cookieService.HasConsentAsync("analytics"))
        {
            _analyticsService.TrackSearch(query);
        }

        return View(results);
    }
}

With Form Submissions

Gate form tracking behind consent:

public class ContactFormController : SurfaceController
{
    [HttpPost]
    public async Task<IActionResult> Submit(ContactForm form)
    {
        // Always process the form
        await _formService.ProcessAsync(form);

        // Only track conversion if consent given
        if (await _cookieService.HasConsentAsync("marketing"))
        {
            await _conversionService.TrackFormSubmissionAsync();
        }

        return Redirect("/thank-you");
    }
}

Troubleshooting

Banner Not Appearing

  1. Verify Domain ID is correct in appsettings.json
  2. Check _GetCookieWidget partial is in the layout
  3. Ensure no JavaScript errors in browser console
  4. Verify domain is active in GetCookies dashboard

Backoffice Section Missing

  1. Clear Umbraco runtime cache
  2. Restart the application
  3. Verify user has access to the GetCookie section

Script Blocking Not Working

  1. Ensure type="text/plain" attribute is set
  2. Verify data-olc-category matches your category ID
  3. Check that _GetCookieHead partial loads before the blocked script

Getting Started

  1. Install package via NuGet
  2. Add configuration to appsettings.json
  3. Register services in Program.cs
  4. Add partials to your layout
  5. Configure banner in GetCookies dashboard

Umbraco developers shouldn't have to build consent management from scratch. GetCookie brings enterprise compliance to .NET with native tooling.

자주 묻는 질문

Which Umbraco versions are supported?
GetCookie supports Umbraco 10, 11, 12, and 13, running on .NET 6, 7, or 8. Install via NuGet with standard package management.
Does the Umbraco package include a backoffice dashboard?
Yes, the package adds a consent analytics dashboard to your Umbraco backoffice where editors can view consent rates and scan results without developer involvement.
How do I install GetCookie on Umbraco?
Run `dotnet add package GetCookie.Umbraco`, add the configuration to appsettings.json, and add the Tag Helper to your layout. Full integration in under 10 minutes.
G

GetCookies 팀

노르웨이 오슬로 Getia AS의 GetCookies 팀이 작성하고 관리합니다. 이 글은 쿠키 동의에 관한 일반 정보이며 법률 자문이 아닙니다.

내 사이트를 무료로 스캔하세요

무료 플랜은 사이트 1개에 배너를 표시하고 매월 쿠키 스캔 3회를 제공합니다. 카드 등록도, 영업 전화도 없습니다.