(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8069],{3330:function(e,n,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/advanced/javascript-api",function(){return s(5258)}])},5258:function(e,n,s){"use strict";s.r(n),s.d(n,{__toc:function(){return l}});var o=s(5893),i=s(2673),a=s(7913),t=s(2702);s(9128);var r=s(2643);let l=[{depth:2,value:"Events",id:"events"},{depth:2,value:"Public methods",id:"public-methods"}];function _createMdxContent(e){let n=Object.assign({h1:"h1",p:"p",h2:"h2",ul:"ul",li:"li",strong:"strong",pre:"pre",code:"code",span:"span"},(0,r.a)(),e.components);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h1,{children:"Javascript API"}),"\n",(0,o.jsx)(n.p,{children:"CookieHub provides a flexible JavaScript API that allows you to extend its functionality and integrate it seamlessly with your website. This API includes a set of events and methods to help you customize user experiences related to cookie consent. Here's a comprehensive guide to using the CookieHub JavaScript API."}),"\n",(0,o.jsx)(n.h2,{id:"events",children:"Events"}),"\n",(0,o.jsx)(n.p,{children:"CookieHub events are triggered at different points in the consent process, allowing you to take specific actions in response. Here's a list of available events:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"onInitialise(status)"}),": Fired when CookieHub has finished loading. You can use this event to execute custom code based on the user's initial consent status."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"onAllow(category)"}),": Triggered whenever a user allows a cookie category that was previously disallowed. This event helps you react to changes in cookie preferences."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"onRevoke(category)"}),": Activated when a user revokes consent for a previously allowed cookie category. Use this event to handle consent changes."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.strong,{children:"onStatusChange(status, previousState)"}),': Fired when users modify their cookie preferences, such as by clicking the "Save Settings" button or allowing all cookies. This event helps you track changes in user consent.']}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"The following example demonstrates how to use these events:"}),"\n",(0,o.jsx)(n.pre,{"data-language":"javascript","data-theme":"default",children:(0,o.jsxs)(n.code,{"data-language":"javascript","data-theme":"default",children:[(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"var"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" cpm "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"onInitialise"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"function"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"(status) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"if"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"this"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".hasConsented"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'analytics'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:")) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"      "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"console"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".log"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'The analytics category is allowed'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:");"})]}),"\n",(0,o.jsx)(n.span,{className:"line",children:(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    }"})}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  }"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"onStatusChange"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"function"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"(status"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" previousStatus) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"if"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"this"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".hasConsented"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"analytics"'}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:")) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"      "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"console"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".log"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'The analytics category is allowed'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:");"})]}),"\n",(0,o.jsx)(n.span,{className:"line",children:(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    }"})}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  }"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"onAllow"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"function"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"(category) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"if"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" (category "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"=="}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'analytics'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:") {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"      "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"console"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".log"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'The analytics category was just allowed'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:");"})]}),"\n",(0,o.jsx)(n.span,{className:"line",children:(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    }"})}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  }"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"onRevoke"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"function"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"(category) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"if"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" (category "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"=="}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'analytics'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:") {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"      "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"console"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".log"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'The analytics category was just revoked'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:");"})]}),"\n",(0,o.jsx)(n.span,{className:"line",children:(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"    }"})}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  }"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,o.jsx)(n.span,{className:"line",children:(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"};"})})]})}),"\n",(0,o.jsx)(n.p,{children:"Note: The above example is integrated with the default CookieHub JavaScript code."}),"\n",(0,o.jsx)(n.h2,{id:"public-methods",children:"Public methods"}),"\n",(0,o.jsx)(n.p,{children:"CookieHub provides several public methods that you can use to enhance its functionality:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"load(options)"}),": This method initializes CookieHub. It should be part of the default provided code and should only be called once on each page load. Any attempt to initialize CookieHub again will be ignored.",(0,o.jsx)("br",{}),"\n- options (object): An object containing a list of options and events."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"hasAnswered()"}),": Checks if the user has already made cookie choices by allowing all cookies or saving settings. This method doesn't accept any parameters."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"hasConsented(category)"}),": Checks if the user has allowed the specified cookie category.",(0,o.jsx)("br",{}),"\n- category (string): The name or ID of the cookie category to check."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"isSellingAllowed():"})," Returns true if the user has not opted-out of selling and sharing of personal information. This method is available in version >=2.8.1."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"isSharingAllowed():"})," Returns true if the user has not opted-out of selling and sharing of personal information. This method is available in version >=2.8.1."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"openDialog():"})," Opens the CookieHub dialog, typically displayed on the first load."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"closeDialog()"}),": Closes the CookieHub dialog if it's still open."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"openSettings()"}),": Opens the CookieHub settings dialog. Useful if you've hidden the settings icon and want to create a custom link or button for opening the settings dialog."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"openPersonalData()"}),": Opens the CookieHub settings dialog with the personal data tab selected."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"closeSettings()"}),": Closes the CookieHub settings dialog."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"allowAll()"}),": Allows all cookie categories. This method offers an alternative way for users to consent to all categories."]}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"denyAll()"}),": Denies all cookie categories. Similar to allowAll(), this method offers an alternative way for users to revoke consent for all categories."]}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"Here's a sample usage of these methods:"}),"\n",(0,o.jsx)(n.pre,{"data-language":"javascript","data-theme":"default",children:(0,o.jsxs)(n.code,{"data-language":"javascript","data-theme":"default",children:[(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"if"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".hasAnswered"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"()) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"console"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".log"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'User has answered'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:");"})]}),"\n",(0,o.jsx)(n.span,{className:"line",children:(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"}"})}),"\n",(0,o.jsx)(n.span,{className:"line",children:" "}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"if"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".hasConsented"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"analytics"'}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:")) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"console"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".log"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'Analytics category is allowed'"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:");"})]}),"\n",(0,o.jsx)(n.span,{className:"line",children:(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"}"})}),"\n",(0,o.jsx)(n.span,{className:"line",children:" "}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"if"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ("}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"!"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".hasAnswered"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"()) {"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"  "}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".openDialog"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"();"})]}),"\n",(0,o.jsx)(n.span,{className:"line",children:(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"}"})}),"\n",(0,o.jsx)(n.span,{className:"line",children:" "}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".closeDialog"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"();"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".openSettings"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"();"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".closeSettings"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"();"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".allowAll"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"();"})]}),"\n",(0,o.jsxs)(n.span,{className:"line",children:[(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"window"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"cookiehub"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".denyAll"}),(0,o.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"();"})]})]})}),"\n",(0,o.jsx)(n.p,{children:"By leveraging the CookieHub JavaScript API, you can create a personalized and compliant cookie consent experience for your website visitors."})]})}let c={MDXContent:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:n}=Object.assign({},(0,r.a)(),e.components);return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(_createMdxContent,{...e})}):_createMdxContent(e)},pageOpts:{filePath:"pages/advanced/javascript-api.mdx",route:"/advanced/javascript-api",timestamp:1728649812e3,pageMap:[{kind:"Meta",data:{index:{title:"Home",type:"page",display:"hidden"},"getting-started":{title:"Getting started",type:"page"},features:{title:"Features",type:"page"},installation:{title:"Installation",type:"page"},dashboard:{title:"Dashboard",type:"page"},advanced:{title:"Advanced",type:"page"}}},{kind:"Folder",name:"advanced",route:"/advanced",children:[{kind:"Meta",data:{index:"Introduction","google-tag-manager":"Google Tag Manager","consent-mode-v2-signals":"Consent mode v2 signals","javascript-api":"Javascript API",services:"External services",csp:"Content Security Policy (CSP)","known-issues":"Known issues & workarounds"}},{kind:"MdxPage",name:"consent-mode-v2-signals",route:"/advanced/consent-mode-v2-signals"},{kind:"MdxPage",name:"csp",route:"/advanced/csp"},{kind:"MdxPage",name:"google-tag-manager",route:"/advanced/google-tag-manager"},{kind:"MdxPage",name:"index",route:"/advanced"},{kind:"MdxPage",name:"javascript-api",route:"/advanced/javascript-api"},{kind:"MdxPage",name:"known-issues",route:"/advanced/known-issues"},{kind:"MdxPage",name:"services",route:"/advanced/services"}]},{kind:"Folder",name:"dashboard",route:"/dashboard",children:[{kind:"Meta",data:{index:"Getting started",authentication:"Authentication",account:"Account",vendors:"Vendors",services:"Services",billing:"Billing","---":{type:"separator",title:"Domains"},"domain-overview":"Overview","add-domain":"Add domain","domain-settings":"Domain settings",implementation:"Implementation",customization:"Customization",languages:"Languages & Translations",regions:"Regions & Policy frameworks","cookie-management":"Cookie management",scans:"Scans","consent-log":"Consent log",reports:"Reports"}},{kind:"MdxPage",name:"account",route:"/dashboard/account"},{kind:"MdxPage",name:"add-domain",route:"/dashboard/add-domain"},{kind:"MdxPage",name:"authentication",route:"/dashboard/authentication"},{kind:"MdxPage",name:"billing",route:"/dashboard/billing"},{kind:"MdxPage",name:"consent-log",route:"/dashboard/consent-log"},{kind:"MdxPage",name:"cookie-management",route:"/dashboard/cookie-management"},{kind:"MdxPage",name:"customization",route:"/dashboard/customization"},{kind:"MdxPage",name:"domain-overview",route:"/dashboard/domain-overview"},{kind:"MdxPage",name:"domain-settings",route:"/dashboard/domain-settings"},{kind:"MdxPage",name:"implementation",route:"/dashboard/implementation"},{kind:"MdxPage",name:"index",route:"/dashboard"},{kind:"MdxPage",name:"languages",route:"/dashboard/languages"},{kind:"MdxPage",name:"regions",route:"/dashboard/regions"},{kind:"MdxPage",name:"reports",route:"/dashboard/reports"},{kind:"MdxPage",name:"scans",route:"/dashboard/scans"},{kind:"MdxPage",name:"services",route:"/dashboard/services"},{kind:"MdxPage",name:"vendors",route:"/dashboard/vendors"}]},{kind:"Folder",name:"features",route:"/features",children:[{kind:"Meta",data:{index:"Introduction","cookie-scanner":"Cookie scanner","cookie-declaration":"Cookie declaration","automatic-cookie-blocker":"Automatic cookie blocker",regions:"Regions / Geo-targeting",languages:"Languages & translations","policy-frameworks":"Policy frameworks","consent-log":"Consent log",accessibility:"Accessibility",linker:"Linker",reports:"Reports","---":{type:"separator",title:"Integrations"},"google-tag-manager":"Google Tag Manager","google-consent-mode":"Consent mode","shopify-customer-privacy":"Shopify Customer Privacy API","iab-tcf":"IAB Transparency and Consent Framework (TCF)","google-additional-consent-mode":"Google Additional Consent Mode","iab-gpp":"IAB Global Privacy Platform Framework (GPP)","iab-us-privacy":"IAB US Privacy (CCPA)","global-privacy-control":"Global Privacy Control"}},{kind:"MdxPage",name:"accessibility",route:"/features/accessibility"},{kind:"MdxPage",name:"automatic-cookie-blocker",route:"/features/automatic-cookie-blocker"},{kind:"MdxPage",name:"consent-log",route:"/features/consent-log"},{kind:"MdxPage",name:"cookie-declaration",route:"/features/cookie-declaration"},{kind:"MdxPage",name:"cookie-scanner",route:"/features/cookie-scanner"},{kind:"MdxPage",name:"global-privacy-control",route:"/features/global-privacy-control"},{kind:"MdxPage",name:"google-additional-consent-mode",route:"/features/google-additional-consent-mode"},{kind:"MdxPage",name:"google-consent-mode",route:"/features/google-consent-mode"},{kind:"MdxPage",name:"google-tag-manager",route:"/features/google-tag-manager"},{kind:"MdxPage",name:"iab-gpp",route:"/features/iab-gpp"},{kind:"MdxPage",name:"iab-tcf",route:"/features/iab-tcf"},{kind:"MdxPage",name:"iab-us-privacy",route:"/features/iab-us-privacy"},{kind:"MdxPage",name:"index",route:"/features"},{kind:"MdxPage",name:"languages",route:"/features/languages"},{kind:"MdxPage",name:"linker",route:"/features/linker"},{kind:"MdxPage",name:"policy-frameworks",route:"/features/policy-frameworks"},{kind:"MdxPage",name:"regions",route:"/features/regions"},{kind:"MdxPage",name:"reports",route:"/features/reports"},{kind:"MdxPage",name:"shopify-customer-privacy",route:"/features/shopify-customer-privacy"}]},{kind:"Folder",name:"getting-started",route:"/getting-started",children:[{kind:"Meta",data:{index:"Introduction","cookie-categories":"Cookie categories","subscriptions-and-pricing":"Subscriptions & pricing","resellers-affiliates":"Reseller & affiliates","data-processing-and-security":"Data Processing & Security",faq:"FAQ",support:"Support","change-log":"Change log","release-notes":"Release notes"}},{kind:"MdxPage",name:"change-log",route:"/getting-started/change-log"},{kind:"MdxPage",name:"cookie-categories",route:"/getting-started/cookie-categories"},{kind:"MdxPage",name:"data-processing-and-security",route:"/getting-started/data-processing-and-security"},{kind:"MdxPage",name:"faq",route:"/getting-started/faq"},{kind:"MdxPage",name:"index",route:"/getting-started"},{kind:"Folder",name:"release-notes",route:"/getting-started/release-notes",children:[{kind:"MdxPage",name:"cookiehub-2.7",route:"/getting-started/release-notes/cookiehub-2.7"},{kind:"Meta",data:{"cookiehub-2.7":"Cookiehub 2.7"}}]},{kind:"MdxPage",name:"resellers-affiliates",route:"/getting-started/resellers-affiliates"},{kind:"MdxPage",name:"subscriptions-and-pricing",route:"/getting-started/subscriptions-and-pricing"},{kind:"MdxPage",name:"support",route:"/getting-started/support",frontMatter:{title:"Support",sidebar_position:200}}]},{kind:"MdxPage",name:"index",route:"/"},{kind:"Folder",name:"installation",route:"/installation",children:[{kind:"Meta",data:{index:"Getting started","upgrade-v2.8":"Upgrade guide","consent-mode-v2":"Consent mode","-":{type:"separator",title:"Tag installation"},tag:"Installation","content-management-systems":"Content Management Systems",wordpress:"Wordpress",matomo:"Matomo Tag Manager",troubleshooting:"Troubleshooting","---":{type:"separator",title:"Google Tag Manager"},"google-tag-manager":"Installation","google-tag-manager-upgrade":"Upgrade","additional-consent":"Additional consent","consent-overview":"Consent overview","----":{type:"separator",title:"Digging deeper"},"conditional-html-tags":"Conditional HTML tags","cookie-declaration":"Cookie declaration","resurface-dialog":"Resurface dialog",linker:"Linker"}},{kind:"MdxPage",name:"additional-consent",route:"/installation/additional-consent"},{kind:"MdxPage",name:"conditional-html-tags",route:"/installation/conditional-html-tags"},{kind:"MdxPage",name:"consent-mode-v2",route:"/installation/consent-mode-v2"},{kind:"MdxPage",name:"consent-overview",route:"/installation/consent-overview"},{kind:"MdxPage",name:"content-management-systems",route:"/installation/content-management-systems"},{kind:"MdxPage",name:"cookie-declaration",route:"/installation/cookie-declaration"},{kind:"MdxPage",name:"google-tag-manager-upgrade",route:"/installation/google-tag-manager-upgrade"},{kind:"MdxPage",name:"google-tag-manager",route:"/installation/google-tag-manager"},{kind:"MdxPage",name:"index",route:"/installation"},{kind:"MdxPage",name:"linker",route:"/installation/linker"},{kind:"MdxPage",name:"matomo",route:"/installation/matomo"},{kind:"MdxPage",name:"resurface-dialog",route:"/installation/resurface-dialog"},{kind:"MdxPage",name:"tag",route:"/installation/tag"},{kind:"MdxPage",name:"troubleshooting",route:"/installation/troubleshooting"},{kind:"MdxPage",name:"upgrade-v2.8",route:"/installation/upgrade-v2.8"},{kind:"MdxPage",name:"wordpress",route:"/installation/wordpress"}]}],flexsearch:{codeblocks:!0},title:"Javascript API",headings:l},pageNextRoute:"/advanced/javascript-api",nextraLayout:a.ZP,themeConfig:t.Z};n.default=(0,i.j)(c)},2702:function(e,n,s){"use strict";var o=s(5893);n.Z={logo:(0,o.jsx)("span",{children:"CookieHub Docs"}),primaryHue:360,primarySaturation:100,editLink:{text:""},feedback:{content:null},sidebar:{defaultMenuCollapseLevel:2,autoCollapse:!0},useNextSeoProps:()=>({titleTemplate:"%s – CookieHub Docs"}),banner:{},footer:{text:(0,o.jsxs)("span",{children:["\xa9",new Date().getFullYear()," CookieHub"]})}}},5789:function(){}},function(e){e.O(0,[9774,4543,2888,179],function(){return e(e.s=3330)}),_N_E=e.O()}]);