?? Need an introduction? Learn configurator options, how to change banner style, position and more in our Cookie Solution beginner’s guide.
In order to enable the iubenda Cookie Solution simply insert the following code before the closing of the HEAD
Tag
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"siteId": XXXXXX, //use your siteId
"cookiePolicyId": YYYYYY, //use your cookiePolicyId
"banner": {
"position": "float-top-center",
"acceptButtonDisplay": true,
"customizeButtonDisplay": true
}
};
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" async></script>
The code shown above is an example. To generate your own code, just click on Activate / Edit Cookie Solution located on the edit page of each website in your iubenda dashboard.
If you are a WordPress user, you can configure the iubenda Cookie Solution by adding the code within the file header.php of the theme you are using before the closing of the HEAD
tag.
Alternatively, we also offer a dedicated plugin that further simplifies the task. You can find more information about it in the dedicated WordPress guide.
In order to configure the iubenda Cookie Solution on a Joomla! website, you can either install a module like the Custom HTML advanced module or use our Joomla! plugin linked below. Here’s an article that explains how to use the HTML module to integrate the privacy policy generated with iubenda. We remind you that, as always, the iubenda Cookie Solution code must be entered before the closing of the HEAD
tag.
The Cookie Solution may also be configured on a Joomla! site using the dedicated Joomla! plugin. For more information, please read the comprehensive guide to the iubenda plugin for Joomla!.
Available parameters _iub.csConfiguration {}
:
siteId:
– Your site’s ID code (notice: This ID is used to share the preference among multiple cookies policies in different languages that are attributable to the same website/app)
cookiePolicyId:
– Your cookie policy’s ID code
lang:
– This parameter defines the language in which to display the content of the cookie banner (for example, “it” for the Italian, “en” for English, “es” for Spanish, etc..). All the language localizations available within the generator are also available for the content of the banner.
Major advertising networks now require publishers to gain consent before showing personalized ads. In this guide you’ll find out how you can meet this requirement with the IAB Transparency and Consent Framework and our Cookie Solution.
enableCMP
or enableTcf
(boolean, default false) – If true, users will be able to manage their advertising tracking preferences according to the IAB Transparency and Consent Framework.
googleAdditionalConsentMode
(boolean, default false) – If set to true, you’ll be able to gather consent for Google ad partners that are not yet part of the Transparency and Consent Framework but are on Google’s Ad Tech Providers (ATP) list. This feature is currently available via the current channel.
tcfVersion
(number, default 1) – If set to 2, it enables the support of the newest version of the Transparency and Consent Framework. Read our transition guide to understand all the new features and benefits that come with TCF v2.0
tcfPurposes:
(object) – TCF v2.0 has 10 purposes, each having an id:
With TCF v2.0 you can:
Here’s how to do it. Thanks to tcfPurposes
, in the following example we’ll:
consent_not_needed
, possible only if our legislation does not require consent for this purpose) *,false
),li_only
) for purpose number 4 (“Select personalised ads”), andconsent_only
) for purpose number 7 (“Measure ad performance”)_iub.csConfiguration = {
"lang": "en",
"siteId": xxxxxx, //use your siteId
"cookiePolicyId": yyyyyy, //use your cookiePolicyId
"enableTcf": true,
"tcfVersion": 2,
...
"tcfPurposes": {
"1": "consent_not_needed",
"2": false,
"4": "li_only",
"7": "consent_only"
},
"tcfPublisherCC": "DE",
"isTCFConsentGlobal": false,
"banner": {
...
}
}
* Note about PurposeOneTreatment
: Previously, in some countries it was not required get user consent for purpose number 1 (“Store and/or access information on a device”). In those cases, asking for consent for purpose one could be disabled by using "1": "consent_not_needed"
. However since this option should only be enabled if legally supported by the legislation that applies to you, and, at the time of writing, no EU country currently supports this legislatively – we strong advise against using it.
askConsentIfCMPNotFound
(boolean, default true) – If set to true, and the IAB Framework preference is not found, the Cookie Solution will, by default, request a new consent from users that had provided consent prior to the activation of the Framework. Set this option to false to disable this default behavior.
isTCFConsentGlobal
(boolean, default true) – If set to true, the TCF consent is saved on both consensu.org and local. If set to false, the TCF consent is saved only on the local domain (meaning the TCF cookie won’t be shared with other publishers). This value proxies the IAB CMP JS API hasGlobalScope
value.
newConsentAtVendorListUpdate
(number, default undefined) – Number of days to wait to trigger a new consent request after the vendorlist.json is updated. If set to undefined, users who have already given consent will not be shown the cookie banner again, and consent for new vendors will be set to off. If set to 0 users will get prompted with a new consent request whenever the vendor list is updated.
iubenda-advertising-preferences-link
– By adding this class to any element of the page, the click on the item triggers the opening of the advertising tracking settings modal (allowing users to update their TCF preferences even after closing the cookie banner).
Please note that as an alternative to this specific TCF class, you can also use the “generic” iubenda-cs-preferences-link
, the result will be the same.
whitelabel:
(boolean, default true) – Set this parameter to false to show the iubenda branding on the second layer.
floatingPreferencesButtonDisplay:
(string, default false) – It defines the position of the privacy widget (a feature that allows your users to access and edit tracking preferences at any time after setting their initial preferences). Available values: false, true, top-left, top-right, bottom-left, bottom-right (default if set to true), anchored-center-left, anchored-center-right, anchored-top-left, anchored-top-right, anchored-bottom-left, anchored-bottom-right.
floatingPreferencesButtonCaption:
(string, default false) – Text of the privacy widget button.
floatingPreferencesButtonIcon:
(boolean, default true) – Icon of the privacy widget button.
floatingPreferencesButtonHover:
(boolean, default false) – Shows the privacy widget text on hover.
floatingPreferencesButtonRound:
(boolean, default false) – Adds the iubenda-tp-circle
attribute to the privacy widget button.
floatingPreferencesButtonColor:
(string, default “#fff”) – Background color of the privacy widget button.
floatingPreferencesButtonCaptionColor:
(string, default “#000”) – Text color of the privacy widget button.
consentOnScroll:
(boolean, default true) – You can set this parameter to false to avoid the registration of the user’s consent when the page is scrolled.
consentOnLinkAndButton:
(boolean, default true) – The user’s consent is normally recorded also after a click on a button (button
) on the page, as well as on the links (a
). Set to false, the consentOnLinkAndButton
parameter (formerly consentOnButton
) changes the default behavior by ensuring that the consent results as “not given” in these cases.
consentOnElement:
(string|DOMElement, default “input, textarea, form”) – The user’s consent is recorded by clicking on one of the html elements (including selectors like classes and ids) listed in the parameter. Unlike consentOnLinkAndButton
(see above), the option does not manage the tags a
and button
. Important: if new html elements are added and you need the default elements to be still active, you must declare them again.
consentOnDocument:
(boolean, default false) – If set to true, the user’s consent will be registered if you click anywhere on the page (excluding the banner area).
consentOnContinuedBrowsing:
(boolean, default true) – If set to false, consentOnScroll
, consentOnDocument
and consentOnLinkAndButton
are set to false, and consentOnElement
is set to no element. This way you only accept explicit consent, while consent on scroll and page interaction is not given.
consentOnScrollHorizontal:
(boolean, default false) – By setting this parameter to true, the consent is given even in cases of horizontal scrolling.
consentOnScrollOnElement:
(string|DOMElement, default null) – The scrolling event is observed on the element passed as a parameter (including selectors like classes and ids). The DOM element may not yet be available when the Cookie Solution is initialized. In this case, you can use the setConsentOnScrollOnElement
API method.
localConsentDomain:
(string, default null) – the domain on which you want to save the consent collected from the users. If not set, the consent will be saved in a cookie on the domain of the current page (for example, by visiting www.example.com, the consent will be saved in a cookie placed in the domain example.com). If the default behavior is not appropriate, for example, if the website is located on the domain www.paesaggiurbani.italia.it the consent must be provided for paesaggiurbani.italia.it (and not for italia.it), in that case, you are required to set the localConsentDomain to the value ‘paesaggiurbani.italia.it’.
Notice: in a similar scenario, if the parameter is not given, the banner could continue to appear to the same user at each subsequent visit/page view.
localConsentPath:
(string, default ‘/’) – The path within the local domain, in which you want to save the consent provided by the user. By default, the user’s consent is saved in the local domain within the cookie in the path ‘/’. This way, the cookie is available regardless of the page of the domain being accessed. If you, for example, don’t want the preference cookie set for www.example.com/percorso1 to also apply to www.example.com/percorso2 (by browsing), and vice versa, you will need to provide the value ‘/percorso1’ for this parameter in the first case, and ‘/percorso2’ in the second case.
perPurposeConsent:
(boolean, default false) – Setting this parameter to true gives users granular control over which categories of cookies they consent to (see below). The categories are displayed along with a short description and toggle so that users can either grant or reject consent for the particular processing purpose. The categories displayed in the modal are automatically detected and passed from your iubenda cookie policy to the Cookie Solution. However, the categories displayed can also be customized by using the purposes
parameter below.
Please note that, currently, our Magento plugin doesn’t support the auto-assignment of categories when blocking scripts. This simply means that, currently, on Magento you’ll need to tag scripts manually or by using something like Google Tag Manager. In both instances, please be sure to individually include the corresponding purpose parameter. For GTM click here, and manual tagging here.
Examples:
If you’ve enabled the per-category consent feature you’ll need to specify the categories of scripts that install cookies prior to consent with a special comma-separated data-iub-purposes
attribute. Read this guide for further instructions and examples on using manual tagging and per-category consent.
purposes:
(string, default null) – Purposes are grouped into 5 categories (strictly necessary, basic interactions & functionalities, experience enhancement, measurement, targeting & advertising), each having an id (1, 2, 3, 4, 5). By default, we use the purposes from the iubenda cookie policy connected to your configuration, but you can customize which categories to display with purposes
(for example, if you use your own cookie policy).
Here are the purposes included in each category:
1
). Purposes included:2
). Purposes included:3
). Purposes included:4
). Purposes included:5
). Purposes included:So, for example, if you’re using all 5 categories, and you’re not using an iubenda cookie policy, you’ll need to specify "purposes": "1, 2, 3, 4, 5"
, if you don’t use Measurement (id 4) you can simply specify "purposes": "1, 2, 3, 5"
and so on.
Note: to be effective, this parameter requires the parameter perPurposeConsent
to be set to true (see above for further details).
skipSaveConsent:
(boolean, default false) – By setting this parameter to true, the consent is not saved in a preference cookie.
invalidateConsentBefore:
(“YYYY-MM-DD”, milliseconds from epoch, default null) – All consents collected prior to this date will be invalidated. Consents collected on this date and in the future will not be invalidated.
maxCookieSize:
(number, default 4096) – To avoid browsers reject cookies longer than 4096 characters, the Cookie Solution allows to split cookies in multiple chunks. With maxCookieSize
you can configure the maximum length of every chunk (see also maxCookieChunks
).
maxCookieChunks:
(number, default 5) – With this parameter you can configure the maximum number of chunks into which cookies can be split (see also maxCookieSize
).
Note: if the cookie to be saved is longer than maxCookieSize
* maxCookieChunks
(20480 chars with default values), then the cookie is not saved.
reloadOnConsent:
(boolean, default false) – You can set this parameter to true if you want the page to be reloaded after the collection of the consent.
enableRemoteConsent:
(boolean, default false) – You can set this parameter to true to enable a cross-site registration of the consent (it can be useful when the script is implemented in more than one websites of the same network). In particular, if you set this parameter to true, our solution creates a technical cookie on iubenda.com (domain) which is used when the cookie on the local domain is not found.
askConsentAtCookiePolicyUpdate:
(boolean, default false) –?You can set this parameter to true if you want to request new consent when the Cookie Policy is updated.
priorConsent:
(boolean, default true) – Enables the blocking of scripts and their reactivation only after having collected user consent. If false, the blocked scripts are always reactivated regardless of whether or not consent has been provided (useful for testing purposes, or when you’re working on your project locally and don’t want pageviews to be counted).
We strongly advise against setting "priorConsent":false
if you need to comply with EU legislation. Please note that if the prior blocking setting has been disabled server side (via the checkbox on the flow page), this parameter will be ineffective whether it’s set to true
or false
.
countryDetection:
(boolean, default false) – Allows you to autodetect and limit prior-blocking and cookie consent requests only to users from the EU – where this is a legal requirement – while running cookies scripts normally in regions where you are still legally allowed to do so. Set this parameter to true if gdprAppliesGlobally
is set to false and you want to automatically detect the user country. If you disable this option, remember to set gdprApplies:false
on all page views where the consent is not being requested.
You can also override the detected country by passing the _iub.cc
variable at iubenda_cs.js onload
. Right now we only accept _iub.cc = 'EU';
(European Union) and delete _iub.cc;
(other countries) as _iub.cc
possible values. For example, if you want to force EU:
<script type="text/javascript" src="http://cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" onload="_iub.cc = 'EU';" async></script>
You can test this feature on CodePen.
enableGdpr:
(boolean, default true) – If true, you’ll enable/make available the GDPR functionality in the Cookie Solution (without actually applying it).
gdprAppliesGlobally:
(boolean, default true) – If true, you’ll apply GDPR protections to all users. Set this parameter to false and countryDetection:true
to request consent to EU users only. Remember that if you’re based in the EU you must apply the GDPR also to users based outside of the EU.
gdprApplies:
(boolean, default true) – If false, you won’t apply GDPR protections to the current user and he will not be shown the cookie banner. If you’ve set countryDetection:false
, you should set gdprApplies:false
on all page views where the consent is not being requested.
enableCcpa:
(boolean, default false) – If true, you’ll enable/make available the CCPA functionality in the Cookie Solution (without actually applying it).
ccpaApplies:
(boolean, default undefined) – If true, you’ll apply CCPA protections to the current user.
ccpaNoticeDisplay:
(boolean, default true) – If false, you won’t display an actual banner to notify users about CCPA (effective only if GDPR doesn’t apply).
ccpaAcknowledgeOnDisplay:
(boolean, default false) – If ccpaNoticeDisplay: true
, allows you to specify what constitutes acknowledgment of the notice: the simple loading of the notice (true) or the explicit interaction after the notice has loaded (false).
ccpaLspa:
(boolean, default undefined) – Allows you to specify whether the transaction should be performed under the Limited Service Provider Agreement (LSPA) by IAB.
Classes:
iubenda-ccpa-opt-out
– By adding this class to any element of the page, the click on the item triggers the opening of a dialog where the user can confirm their intention to opt-out from the sale of their personal information (“Do Not Sell My Personal Information” link).Here are additional optional parameters that call for the definition of one or more objects:
footer {}
(object)
btnCaption (string) – Text of the button (located at the bottom of the “Tracking preferences” window, see per-category consent) used to save the consent preferences. The default value is “Save and continue”.
i18n {}
(object) – You can translate/edit the texts of any Cookie Solution component via the i18n JavaScript library. See this demo on CodePen for a list of all components/strings you can edit and/or localize.
Important: if you’ve enabled the Transparency and Consent Framework, in order to meet IAB’s minimum configuration requirements, you must necessarily use the official translations (see “List of translations for purpose descriptions v2.0”).
callback {}
(object) – This is the parameter through which you can define the callback that iubenda Cookie Solution can perform upon the occurrence of an event, namely:
onReady (function) – If the consent of the user has not yet been processed (for example, because it’s his first visit) the onReady callback is invoked as soon as the banner cookie is displayed; on the contrary, if the user has already given their consent to the installation of cookies, this callback is invoked as soon as the iubenda Cookie Solution is initialized. The consent given or not is passed as an argument, which can be true or false.
onBannerShown (function) – Using this feature you can run a script when the banner is shown.
onBannerClosed (function) – Using this feature you can run a script when the banner is closed.
onCookiePolicyShown (function) – Called when the cookie policy is shown (either in modal window or on a separate page).
onConsentGiven (function) – This callback is invoked if the user has given the consent to the installation of cookies, both when consenting for the first time and in all subsequent visits.
onConsentFirstGiven (function) – It is invoked only for the first time that the user gives their consent. One of the following strings is passed as an argument: documentScroll, documentMoved, bannerXClose, documentClicked or cookiePolicyClosed.
onConsentRejected (function) – This callback is invoked if the user has rejected the consent to the installation of cookies.
onConsentFirstRejected (function) – Invoked when the consent has been rejected, as soon as the user gives his preference (not on every page view, as onConsentRejected
).
onPreferenceExpressed (function) – It is invoked whenever a preference is expressed, be it accept or reject.
onPreferenceFirstExpressed (function) – Invoked as soon as the user gives his preference (not on every page view, as onPreferenceExpressed
).
onPreferenceExpressedOrNotNeeded (function) – It is invoked whenever a preference is expressed or not needed, for example when:
gdprApplies:true
and the user has expressed his preference, orgdprApplies:false
, orgdprAppliesGlobally:false
, countryDetection:true
and the user is based outside the EUonPreferenceNotNeeded (function) – It is invoked whenever a preference is not needed, for example when:
gdprApplies:false
, orgdprAppliesGlobally:false
, countryDetection:true
and the user is based outside the EUonConsentRead (function) – It is invoked the first time the user gives consent and each subsequent loading when the consent is detected. The callback onConsentGiven becomes an alias for onConsentRead and it is not invoked if the latter is defined.
onStartupFailed (function) – It is invoked in the case where the iubenda Cookie Solution fails the startup phase. An error message is passed as an argument.
onError (function) – It is invoked in the case where the iubenda Cookie Solution is experiencing an error. An error message is passed as an argument.
onFatalError (function) – It is invoked in the case where the iubenda Cookie Solution experiencing an error that does not allow it to continue. An error message is passed as an argument.
onActivationDone (function) – It is invoked when the snippet activation is complete.
onBeforePreload (function) – Invoked when the Cookie Solution preloads, that is before the cookies are loaded.
onCcpaAcknowledged (function) – Invoked when the CCPA notice has been acknowledged.
onCcpaFirstAcknowledged (function) – Invoked the first time the CCPA notice has been acknowledged.
onCcpaOptOut (function) – Invoked when the user has opted out from sale.
onCcpaFirstOptOut (function) – Invoked the first time the user has opted out from sale.
preferenceCookie {}
(object) – This is the parameter through which you can customize the lasting of the preference cookie iubenda installs in the user’s browser in order to record its consent. In particular, the object to be defined is:
ccpaCookie {}
(object) – Allows you to customize the expiration of the cookie that stores the acknowledgment of the notice. In particular, the object to be defined is:
privacyPolicyUrl
(string) – Allows you to customize the privacy policy link.
cookiePolicyUrl
(string) – This is the cookie policy’s URL linked within the banner. It is available in your privacy policy’s edit page in the “integration” tab. If you don’t define this parameter it will refer to the cookie policy generated by iubenda and hosted on our servers. You can alternatively choose to host the cookie policy on a page of your website and thus fill this field with the related URL. Remember that if you decide to host the cookie policy on your own page, this page should not use cookies, beyond the technical ones. Note: this parameter will be ineffective if you are using a custom HTML for the banner (see the configuration banner.html below).
cookiePolicyInOtherWindow
(boolean, default false) – If you set this parameter to true the privacy policy and the cookie policy will open in another window instead of the iubenda modal window.
rebuildIframe
(boolean, default true) – Once the user’s consent has been recorded, the default behavior of the Cookie Solution is to fully regenerate (or reintegrate) the iframes previously modified. By setting this parameter to false, the iframes previously blocked are restored after the collection of consent.
inlineDelay
(integer, milliseconds, default 500) – The maximum time between the activations of snippets tagged with the class _iub_cs_activate-inline
(the snippet tagged in this way are activated sequentially). By decreasing this value you will reduce the total time of activation. Caution: the default value is set in order for the snippets to work properly; reducing it may prevent the successful activation of some snippet. It is highly recommended to check the activation of the snippet shown on your page if this setting is changed.
startOnDomReady
(boolean, default true) – If true banner rendering and/or activation of blocked snippets will be performed as soon as the document status is ‘loaded’ (i.e. when the DOM reaches the ‘loaded’ status). If the option is set to false, then the Cookie Solution will start when the page has been fully loaded (i.e. when the DOM status is ‘completed’ and all resources included in the page have been loaded).
timeoutLoadConfiguration
(integer, milliseconds, default 30000) – The amount of time to wait for the remote configuration before stating that a timeout occurred. In case of a slow network, by increasing this value, you’ll make sure that the Cookie Solution gets the needed resources on time.
logLevel
(string) – It defines the verbosity of the logger (available values: ‘debug’, ‘info’, ‘warn’, ‘error’, ‘fatal’; the default value is ‘nolog’)).
logViaAlert
(boolean, default false) – By setting this parameter to true, the logging is shown via alert.
iubenda-cs-close-btn
– By adding this class to any element of the page, the click on the item closes the banner and assumes that the consent is provided (in an equivalent manner to the click on the X button of the banner).iubenda-cs-cookie-policy-lnk
– By adding this class to any element of the page, the click on that element allows the displaying of the Cookie Policy (it’s equivalent to the click on the link to the Cookie Policy). Note: in order to ensure proper display of the cookie policy, the class iubenda-cs-cookie-policy-lnk
(assigned to the link to the cookie policy in the banner) must not be used elsewhere on the page.iubenda-cs-preferences-link
– Add this class to any element of the page to allow users to update their cookie preferences even after closing the cookie banner.Here is an example of configuration with the optional parameters:
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"siteId": 896537, //use your siteId
"cookiePolicyId": 8207462, //use your cookiePolicyId
"enableRemoteConsent": "false",
"consentOnScroll": "false",
"banner": {
"position": "top",
"slideDown": "false",
"content": "This website or its third-party tools use cookies. Please refer to the %{cookie_policy_link} if you want to learn more or withdraw your consent.",
"cookiePolicyLinkCaption": "cookie policy",
"backgroundColor": "#CCC",
"textColor": "#000",
"fontSize": "14px",
"innerHtmlCloseBtn": "OK"
},
"callback": {
"onPreferenceExpressed": function(preference) {
console.log('onPreferenceExpressed', preference);
}
},
"preferenceCookie": {
"expireAfter": 180
}
};
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" async></script>
Other examples of possible configurations:
It’s possible to include the part of the code relative to the scripts, directly in-page (inline); this code is known as the inline activator. Scripts can be activated through the inline activator even if the iubenda_cs.js primary resource is generically unavailable or in error.
The inline activator only guaranties script activation but can also take on a provided permission (see the following forceSafeActivation
option). It cannot be used to show the banner, the cookie policy or manage the obtaining of consent.
It serves only as another layer of protection in case of errors and does not at all act as a substitute for the main iubenda Cookie Solution code.
Note that the inline activator will only invoke the onActivationDone
, while others will be ignored.
Two additional configuration options are available for the inline activator:
safeTimeout:
(milliseconds, default 0) – the time the inline activator waits before it’s starting to work.forceSafeActivation:
(boolean, default false) – If set to true scripts are activated independently of the given consent. If set to false the inline activator activates the scripts only if consent has been given (as memorized in the preference cookie of the domain of the host page).The inline activator is available at:
If you’ve enabled IAB Transparency and Consent Framework (TCF) compatibility for the customization of advertising tracking preferences, you can use the inline activator both for safe.js
and safe-tcf-v2.js
.
safe-tcf-v2.js
is available at:
The content of safe.js
(and safe-tcf-v2.js
) has to be included in-page after the initial configurations and before the code that loads iubenda_cs.js
.
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"siteId": XXXXXX, //use your siteId
"cookiePolicyId": YYYYYY, //use your cookiePolicyId
"banner": {
"position": "float-top-center",
"acceptButtonDisplay": true,
"customizeButtonDisplay": true
}
};
_iub.csConfiguration.safeTimeout = 500; //custom option
_iub.csConfiguration.forceSafeActivation = false; //custom option
</script>
<!-- inline activator - safe.js (current channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/safe.js and paste here
//]]>
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" async></script>
Sample configuration with IAB TCF v2.0 enabled:
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"enableCMP": true,
"siteId": XXXXXX, //use your siteId
"cookiePolicyId": YYYYYY, //use your cookiePolicyId
"banner": {
"position": "float-top-center",
"acceptButtonDisplay": true,
"customizeButtonDisplay": true
}
};
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/tcf/stub-v2.js"></script>
<!-- inline activator - safe.js (current channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/safe.js and paste here
//]]>
</script>
<!-- inline activator - safe-tcf-v2.js (current channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/tcf/safe-tcf-v2.js and paste here
//]]>
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" async></script>
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"siteId": XXXXXX, //use your siteId
"cookiePolicyId": YYYYYY, //use your cookiePolicyId
"banner": {
"position": "float-top-center",
"acceptButtonDisplay": true,
"customizeButtonDisplay": true
}
};
_iub.csConfiguration.safeTimeout = 500; //custom option
_iub.csConfiguration.forceSafeActivation = false; //custom option
</script>
<!-- inline activator - safe.js (beta channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/beta/safe.js and paste here
//]]>
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/beta/iubenda_cs.js" charset="UTF-8" async></script>
Sample configuration with IAB TCF v2.0 enabled:
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"enableCMP": true,
"siteId": XXXXXX, //use your siteId
"cookiePolicyId": YYYYYY, //use your cookiePolicyId
"banner": {
"position": "float-top-center",
"acceptButtonDisplay": true,
"customizeButtonDisplay": true
}
};
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/tcf/beta/stub-v2.js"></script>
<!-- inline activator - safe.js (beta channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/beta/safe.js and paste here
//]]>
</script>
<!-- inline activator - safe-tcf-v2.js (beta channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/tcf/beta/safe-tcf-v2.js and paste here
//]]>
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/beta/iubenda_cs.js" charset="UTF-8" async></script>
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"siteId": XXXXXX, //use your siteId
"cookiePolicyId": YYYYYY, //use your cookiePolicyId
"banner": {
"position": "float-top-center",
"acceptButtonDisplay": true,
"customizeButtonDisplay": true
}
};
_iub.csConfiguration.safeTimeout = 500; //custom option
_iub.csConfiguration.forceSafeActivation = false; //custom option
</script>
<!-- inline activator - safe.js (stable channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/stable/safe.js and paste here
//]]>
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/stable/iubenda_cs.js" charset="UTF-8" async></script>
Sample configuration with IAB TCF v2.0 enabled:
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"enableCMP": true,
"siteId": XXXXXX, //use your siteId
"cookiePolicyId": YYYYYY, //use your cookiePolicyId
"banner": {
"position": "float-top-center",
"acceptButtonDisplay": true,
"customizeButtonDisplay": true
}
};
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/tcf/stable/stub-v2.js"></script>
<!-- inline activator - safe.js (stable channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/stable/safe.js and paste here
//]]>
</script>
<!-- inline activator - safe-tcf-v2.js (stable channel) -->
<script type="text/javascript">
//<![CDATA[
//copy content from cdn.iubenda.com/cs/tcf/stable/safe-tcf-v2.js and paste here
//]]>
</script>
<script type="text/javascript" src="http://cdn.iubenda.com/cs/stable/iubenda_cs.js" charset="UTF-8" async></script>
The activator code is an integral part of the iubenda Cookie Solution and as such can be modified to include new features, upgrades and fixes.
To facilitate the management of the activator version in your page, the _iub.csSafeActivatorVersion
variable is available, which recalls the iubenda_cs.js version from which the activator was extracted.
The iubenda Cookie Solution features a JS API for easy interaction with some of its main functions.
Syntax: _iub.cs.api.METHOD_NAME
The available methods are:
printErrors()
: prints any errors in the iubenda Cookie Solution on the browser console.
showCP()
: shows the Cookie Policy (similarly to when you click on the link to the Cookie Policy in the banner or on another link with the iubenda-cs-cookie-policy-lnk
class, as described here)
consentGiven()
: provides consent. The method accepts the following as optional parameters:
Note: the call to this method assumes the consent provided is completely equivalent to when it is provided via UI, e.g. with page scrolling. Therefore, all actions downstream of the consent provided are performed, including the updating of the preference cookie, the activation of the previously blocked snippets and the invocation of the onConsentFirstGiven
and onConsentRead
callbacks.
To activate only the snippets there’s the activateSnippets()
method.
activateSnippets()
: activate the previously blocked snippets.
Note: this method can be invoked repeatedly – already-activated snippets will not be taken into account. It is therefore useful in those installations where, upon collection of consent, previously blocked content that now needs to be activated, is dynamically added to the page (e.g. lazy loading or infinite scrolling).
The option runOnActivationDoneCallback
(boolean, default false), if true, will execute the onActivationDone
callback upon completion of the activation of the snippet (see onActivationDone callback).
isConsentGiven()
(DOMElement, default window.document): returns true if the consent was given, otherwise it returns false.
Note: you cannot use this function if you’ve set banner.rejectButtonDisplay: true
or perPurposeConsent: true
. Also, if you’ve enabled the Transparency and Consent Framework, you mandatorily need to add the synchronous activator (safe-tcf-v2.js).
setConsentOnScrollOnElement()
(boolean): the call to this method defines the element on which the scroll will be observed for the purpose of consent.
Note: this method is useful when you want to take advantage of the consentOnScrollOnElement
option, but the DOMelement is not yet available when the Cookie Solution is initialized. In this regard it’s possible to use the onBannerShow
callback (example) which occurs when the CS is initialized.
storeConsent()
: stores consent in cookies. If, for example, you want to migrate consents from a previous provider, you could call this method inside the onBeforePreload
callback when consent is already given by another platform.
gdprApplies()
(boolean): returns true if the GDPR protections are applied to the current user, otherwise it returns false.
ccpaApplies()
(boolean): returns true if the CCPA protections are applied to the current user, otherwise it returns false.
askCcpaOptOut()
: pops up the dialog to request confirmation for the opt-out from sale.
isCcpaAcknowledged()
: returns whether the CCPA notice has been acknowledged.
isCcpaOptedOut()
: returns whether the user has opted out from sale.
Note: you can invoke Cookie Solution API methods also from an iframe.