Skip to content

Commit 85b339e

Browse files
authored
Merge pull request #88 from umbraco/feature/script-based-integration
Cookiebot integration draft
2 parents a96471e + 5efe469 commit 85b339e

File tree

7 files changed

+154
-0
lines changed

7 files changed

+154
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
2+
3+
<PropertyGroup>
4+
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
5+
<EnableDefaultContentItems>false</EnableDefaultContentItems>
6+
<TargetFramework>net6.0</TargetFramework>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<PackageId>Umbraco.Cms.Integrations.Analytics.Cookiebot</PackageId>
13+
<Title>Umbraco CMS Integrations: Analytics - Cookiebot</Title>
14+
<Description>An extension for Umbraco CMS providing an implementation model for Cookiebot banner and declaration.</Description>
15+
<PackageIconUrl></PackageIconUrl>
16+
<PackageProjectUrl>https://github.com/umbraco/Umbraco.Cms.Integrations/blob/main/src/Umbraco.Cms.Integrations.Script.Cookiebot</PackageProjectUrl>
17+
<RepositoryUrl>https://github.com/umbraco/Umbraco.Cms.Integrations</RepositoryUrl>
18+
<Version>1.0.0</Version>
19+
<Authors>Umbraco HQ</Authors>
20+
<Company>Umbraco</Company>
21+
<PackageTags>Umbraco;Umbraco-Marketplace</PackageTags>
22+
<PackageIcon>cookiebot.png</PackageIcon>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Umbraco.Cms.Web.Website" Version="10.0.0" />
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<SupportedPlatform Include="browser" />
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<Content Include="Views\**" />
35+
<Content Include="cookiebot.png">
36+
<Pack>true</Pack>
37+
<PackagePath>\</PackagePath>
38+
</Content>
39+
</ItemGroup>
40+
41+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration
2+
3+
@{
4+
var cbid = Configuration["Umbraco:Cookiebot:Settings:Id"];
5+
}
6+
7+
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js"
8+
data-cbid="@cbid"
9+
data-blockingmode="auto"
10+
type="text/javascript">
11+
</script>
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration
2+
3+
@{
4+
var scriptSrc = "https://consent.cookiebot.com/" + Configuration["Umbraco:Cookiebot:Settings:Id"] + "/cd.js";
5+
}
6+
7+
<script id="CookieDeclaration"
8+
src="@scriptSrc"
9+
type="text/javascript" async>
10+
</script>
11+
4.19 KB
Loading
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Umbraco.Cms.Integrations.Analytics.Cookiebot
2+
3+
This integration provides an implementation model for [Cookiebot](https://www.cookiebot.com/) banner and declaration.
4+
5+
## Prerequisites
6+
7+
Requires minimum versions of Umbraco CMS:
8+
- CMS: 10.0.0
9+
10+
## How To Use
11+
12+
### Configuration
13+
14+
The following configuration is required for the Cookiebot scripts to be loaded correctly:
15+
16+
```
17+
"Umbraco": {
18+
"Cookiebot": {
19+
"Settings": {
20+
"Id": "[YOUR_CBID]"
21+
}
22+
}
23+
}
24+
```
25+
`CBID` = `Cookiebot Identifier`
26+
27+
### Working with the Umbraco CMS - Cookiebot integration
28+
The package is a reusable [Razor class library](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-6.0&tabs=visual-studio) which will allow editors to load the Cookiebot Banner and Declaration scripts.
29+
30+
Per Cookiebot documentation, the Banner script needs to be inserted as the __very first script__ of the website, by placing it in the _HEAD_ tag using this syntax:
31+
32+
`@await Html.PartialAsync("~/Views/Partials/UmbracoCms.Integrations/Analytics/Cookiebot/Banner.cshtml")`
33+
34+
The Declaration script can be added in whatever page you want, using this syntax:
35+
`@await Html.PartialAsync("~/Views/Partials/UmbracoCms.Integrations/Scripts/Cookiebot/Declaration.cshtml")`
36+
37+
Both scripts "pick up" the `CBID` from the website's settings file
38+
`Configuration["Umbraco:Cookiebot:Settings:Id"]`
39+
and update the details accordingly.
40+
41+
42+
### Custom implementations
43+
This integration showcases how easy it is to work with a script-based provider, just by using partial views and Microsoft's `IConfiguration` interface.
44+
45+
You can use this package as reference for creating your own. To do so, please follow these steps:
46+
- Create a new Razor class library for your integration
47+
- Add partial(s) view(s) where you insert your custom script code
48+
- Inject the `IConfiguration` interface into your view: `@inject Microsoft.Extensions.Configuration.IConfiguration Configuration`
49+
- Use `Configuration[YOUR_SETTINGS_PATH:KEY]` to retrieve the required configuration values
50+
- Add `umbraco-markertplace.json` file with Marketplace details of the package
51+
52+
Once your integration is ready, all that remains to do is to deploy the package to NuGet.
53+
You can use [this](https://learn.microsoft.com/en-us/nuget/what-is-nuget) section of the documentation from Microsoft to get started.
54+
55+
56+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"AuthorDetails": {
3+
"Description": "Umbraco HQ",
4+
"Url": "https://umbraco.com/",
5+
"ImageUrl": "https://avatars.githubusercontent.com/u/1419552?s=200&v=4"
6+
},
7+
"Category": "Analytics & Insights",
8+
"LicenseType": "Free",
9+
"PackageType": "Integration",
10+
"PackagesByAuthor": [
11+
"Umbraco.Cms.Integrations.Commerce.CommerceTools",
12+
"Umbraco.Cms.Integrations.Commerce.Shopify",
13+
"Umbraco.Cms.Integrations.SEO.GoogleSearchConsole.URLInspectionTool",
14+
"Umbraco.Cms.Integrations.SEO.Semrush",
15+
"Umbraco.Cms.Integrations.Crm.Hubspot",
16+
"Umbraco.Cms.Integrations.Crm.Dynamics",
17+
"Umbraco.Cms.Integrations.Crm.ActiveCampaign",
18+
"Umbraco.Cms.Integrations.Automation.Zapier",
19+
"Umbraco.Cms.Integrations.Search.Algolia",
20+
"Umbraco.Cms.Integrations.PIM.Inriver"
21+
],
22+
"RelatedPackages": [],
23+
"Tags": [],
24+
"Title": "Cookiebot"
25+
}

src/Umbraco.Cms.Integrations.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Cms.Integrations.PI
7777
EndProject
7878
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Cms.Integrations.Crm.ActiveCampaign.Core", "Umbraco.Cms.Integrations.Crm.ActiveCampaign.Core\Umbraco.Cms.Integrations.Crm.ActiveCampaign.Core.csproj", "{14303AD9-B64B-4DE1-AB4E-B0979277EAC2}"
7979
EndProject
80+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analytics", "Analytics", "{54684516-D990-41C7-885E-96A064A55BB1}"
81+
EndProject
82+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Cms.Integrations.Analytics.Cookiebot", "Umbraco.Cms.Integrations.Analytics.Cookiebot\Umbraco.Cms.Integrations.Analytics.Cookiebot.csproj", "{5CB587DB-D6AD-4AA9-A2FE-52976C5F66C3}"
83+
EndProject
8084
Global
8185
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8286
Debug|Any CPU = Debug|Any CPU
@@ -151,6 +155,10 @@ Global
151155
{14303AD9-B64B-4DE1-AB4E-B0979277EAC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
152156
{14303AD9-B64B-4DE1-AB4E-B0979277EAC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
153157
{14303AD9-B64B-4DE1-AB4E-B0979277EAC2}.Release|Any CPU.Build.0 = Release|Any CPU
158+
{5CB587DB-D6AD-4AA9-A2FE-52976C5F66C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
159+
{5CB587DB-D6AD-4AA9-A2FE-52976C5F66C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
160+
{5CB587DB-D6AD-4AA9-A2FE-52976C5F66C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
161+
{5CB587DB-D6AD-4AA9-A2FE-52976C5F66C3}.Release|Any CPU.Build.0 = Release|Any CPU
154162
EndGlobalSection
155163
GlobalSection(SolutionProperties) = preSolution
156164
HideSolutionNode = FALSE
@@ -178,6 +186,7 @@ Global
178186
{54A624E5-5321-4CC8-B74B-11ABF3605242} = {F2CAA1F7-9BED-4EB6-8875-D176B92D393A}
179187
{904B3CF6-1015-465E-8244-70FC90466F22} = {B5D14B4B-0E39-4C01-9021-D9A75F358DE1}
180188
{14303AD9-B64B-4DE1-AB4E-B0979277EAC2} = {1A4D3D38-F5B2-4528-92A1-318A7D09949D}
189+
{5CB587DB-D6AD-4AA9-A2FE-52976C5F66C3} = {54684516-D990-41C7-885E-96A064A55BB1}
181190
EndGlobalSection
182191
GlobalSection(ExtensibilityGlobals) = postSolution
183192
SolutionGuid = {2FB51E08-A3C8-4DFF-B3CB-E99C2ED021D5}

0 commit comments

Comments
 (0)