Skip to content

Commit

Permalink
Added cookie js script
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbielby committed Feb 12, 2024
1 parent 1650f74 commit 4c30abe
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions js/cookie-consent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function getCookies(){
var res = Cookies.get();
Shiny.setInputValue('cookies', res);
}

Shiny.addCustomMessageHandler('cookie-set', function(msg){
Cookies.set(msg.name, msg.value);
getCookies();
})

Shiny.addCustomMessageHandler('cookie-remove', function(msg){
Cookies.remove(msg.name);
getCookies();
})

$(document).on('shiny:connected', function(ev){
getCookies();
})

Shiny.addCustomMessageHandler('analytics-consent', function(msg){
gtag('consent', 'update', {
'analytics_storage': msg.value
});
})


0 comments on commit 4c30abe

Please sign in to comment.