Making your own pop-up template

This article will walkthrough the most important information for your to create a pop-up template

Piotr avatar
Written by Piotr
Updated over a week ago

How to create a custom template

When creating templates remember that js lib waits for specific events, on clicks to happen and they have to be added to templates with exact names.

Important functions

When customizing your own consent solution you must know the important Javascript functions that make up the solution itself. This is useful for when you want to create your own template for a consent pop-up.

Most important JS functions

  • CookieInformation.submitAllCategories() - Gives consent for all categories. The consent pop-up closes.

<button onclick=
Accept All</button>

  • CookieInformation.declineAllCategories() - Declines for all categories. The consent pop-up closes.

<button onclick=
Decline All</button>

  • CookieInformation.submitConsent() - Gives consent for only selected categories if checkboxes are set. But only when the categories set as the name attribute, are present in the template. The pop-up closes., eg: <input name="cookie_cat_statistic" id="cookie_cat_statistic" type="checkbox" />

<button onclick=
Save settings</button>
  • CookieInformation.getConsentGivenFor(category) - Returns TRUE or FALSE if the category has been consented to.

if (CookieInformation.getConsentGivenFor
{// Do something}

Applying translations for a template

When creating a template, you need to keep in mind that the same template can apply to many domains and languages. That also means that you refrain from hard-coding any text within the template.

Instead, you must use our JS handlebars we have created for each translation field for your solution.

A JS handlebar is is a placeholder that refers to a specific field in our database of translation. This placeholder will get replaced with the correct text based on the chosen translation.

An example of this:


The handlebar consists of the word translations followed by a . (dot) and then the name of the field.

A complete example of usage:

<button onclick="CookieInformation.submitAllCategories()">#{{{translations.accept_cookies_button}}}</button>

Available Handlebars














{{{translations.cookie_purpose_header }}}





















For example, when using the Handlebars template, take note of how each and unless operators are used. Each is used to iterate through categories, and unless uses the boolean value to block the option of disabling the necessary cookies.

<link href="" rel="stylesheet">

<div class="categories-wrapper">
<span class="page-title">{{{translations.category_consent_header}}}</span>
<div class="categories-list">
{{#each cookie_categories}}
<div class="single-category">
<div class="category-title-area">
<span class="category-title">{{{this.cookie_type_name}}}</span>
{{#unless this.is_necessary}}
<div class="switch-container">
<label class="switch">
<input type="checkbox" onclick="CookieInformation.changeCategoryConsentDecision('{{this.cookie_type_label}}')" name="{{this.cookie_type_label}}">
<span class="slider"></span>
<div class="category-description-area">
<div class="category-description">{{{this.cookie_type_description}}}</div>
<span class="more-about-category">{{{../translations.show_details}}}</span>
<div class="consent-decision">
<span class="select-all">{{{translations.multiaccept}}}</span>
<button class="update-consent" onclick="CookieInformation.submitConsent()">{{{translations.update_consent_button}}}</button>

More on how to use the handlebars can be found in the documentation:

Functions provided by the uc.js script

The following functions are accessible to you once the uc.js script has loaded:

CookieInformation._fireEventOnConsentGiven(): Allows you to fire an event upon consent to a particular category (or categories) having been given.

CookieInformation._getConsentScriptUrl(): Returns the URL of the website that the consent has been given for (loaded from the uc.js script).

CookieInformation._getCookieValue(): Returns the value of a cookie that you pass as a parameter.

CookieInformation._getDataCulture(): Returns the data culture of the uc.js script.

CookieInformation._getIABDataCulture(): Returns the data culture of the uc.js script when the IAB TCF 2.2 template is in use.

CookieInformation._getVisitorID(): Returns the visitor ID property.

CookieInformation.getConsentGivenFor(): Returns a boolean of true or false when for whether a particular category has been consented to.

Uploading your new template

If you made a new pop-up template, go to the pop-up tab in the platform under your Consent Solution in the platform.

Under "Advanced Options", you can access each field for the template, HTML, CSS, and JS.

After pasting in the code, press "Save & Publish".

Related articles:

Did this answer your question?