Skip to content

Commit c09917d

Browse files
authored
Provide updateConsentSettings function
2 parents 67b5b98 + 2c128db commit c09917d

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

Readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ Add the following files to your site's layout, they are needed to make the other
3131

3232
### Check if consent has been given
3333
Wrap any libraries that set cookies inside this tag:
34-
`{{ if {cookie_panel:has_consented_to type="group-name"} }}`
34+
`{{ cookie_panel:has_consented_to type="group-name" }}`
3535

3636
e.g
3737

3838
```
39-
{{ if {cookie_panel:has_consented_to type="analytics"} }}
39+
{{ cookie_panel:has_consented_to type="analytics" }}
4040
<!-- Google Tag Manager -->
4141
<script>Bad stuff here</script>
4242
<!-- End Google Tag Manager -->
43-
{{ /if }}
43+
{{ /cookie_panel:has_consented_to }}
4444
```
4545

4646
### Ouput the Cookie Panel

resources/js/cookiepanel.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,18 @@
8181
}
8282
}
8383

84-
localStorage.setItem('consent_settings', selectedCategories.join(','));
84+
updateConsentSettings(selectedCategories);
8585

8686
if (autoClose) {
8787
this.close();
8888
}
8989

90+
}
91+
92+
updateConsentSettings(selectedCategories) {
93+
94+
localStorage.setItem('consent_settings', selectedCategories.join(','));
95+
9096
this.updateScriptConsent(selectedCategories);
9197

9298
window.dispatchEvent(new CustomEvent('statamic-consentpanel:consent-changed', {

0 commit comments

Comments
 (0)