Cookies consent opt out utils not working
@arunpatidar you may be able to help as i see you recently posted a link to the opt out service on this forum question.
I want to use the opt out service in an AEM Sightly template to do cookie consent management.
I am following the documentation linked to above, but i seem to be missing something.
In my local AEM instance, my service is configured OK as i can see at http://localhost:4502/system/console/status-Configurations
PID = com.adobe.granite.optout.impl.OptOutServiceImpl
BundleLocation = Unbound
optout.cookies = [cq-opt-out, omniture_optout]
optout.whitelist.cookies = [cq-show-clientcontext, cq-scrollpos, cq-sk-collapsed, login-token, ys-cq-siteadmin-tree, ys-cq-damadmin-tree, ys-cq-collabadmin-tree, ys-cq-miscadmin-tree, ys-cq-tagadmin, ys-cq-cf-clipboard, ys-cq-cf-tabpanel, SessionPersistence, wcmmode, CommercePersistence, cq-authoring-mode, SH_CAMPAIGN]
service.pid = com.adobe.granite.optout.impl.OptOutServiceImpl
and I am able to include and call browser script methods from Granite.OptOutUtil in a Sightly template in the following way,
<sly data-sly-test="${wcmmode.disabled}">
<sly data-sly-call="${clientlib.all @ categories='granite.utils'}"/>
</sly>
<script>
(function logCookies() {
console.info('whitelisted cookie names? ')
console.table(Granite.OptOutUtil.getWhitelistCookieNames()) // outputs an empty array
console.info('optout cookie names? ')
console.table(Granite.OptOutUtil.getCookieNames()) // outputs an empty array
})()
</script>
but the method calls return empty arrays 😪
Debugging the client-side code in a browser, the Granite.OptOutUtil object is initialised with a config option, that is undefined when the following line executes. What am I missing?
Granite.OptOutUtil.init(window.GraniteOptOutConfig); // window.GraniteOptOutConfig is undefined