Skip to content

Commit

Permalink
Update README, improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
replete committed Jun 9, 2024
1 parent bd4388f commit e21adf5
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ The goal was to make something as small as possible and versatile enough that I
## How to use
```html
<!--
1. Add data-consent="{sectionString}" and type="text/plain" properties
1. Add data-consent="{sectionName}" and type="text/plain" properties
(if you want to only load them upon consent of a section)
(the ids are optional)
-->
<script data-consent="analytics" async src="https://www.googletagmanager.com/gtag/js?id=G-TEST" type="text/plain" id="js-analytics-gtm"></script>
<script data-consent="analytics" type="text/plain" id="js-analytics-gtm-after">
console.log('This script runs as soon as analytics consent is granted')
</script>
<script data-consent="analytics" type="text/plain" id="js-analytics-misc">
console.log('This embedded script will be inserted when analytics consent is granted')
</script>
<!-- for more advanced examples view source of index.html -->

<!--
2. Configure biscuitman global object
Expand Down Expand Up @@ -83,6 +81,37 @@ While you have the option to enable or disable some or all of these cookies, not

```

## Globals
- `biscuitman` – configuration object, must be `window.biscuitman`
- `Consent` – object for accessing consents (add `global` config property to override)
```
{
"consentTime": 1717846660979,
"functional": false,
"analytics": false,
"performance": false,
"advertisement": false,
"uncategorized": false
}
```
- example: `if (Consent && Consent.analytics) { doAnalyticsThing() }`
- `bmInvalidateConsent()` – Delete stored consent data and reinstate UI
- `bmUpdateConsent()` – Opens My Consent Settings modal
- example: `<a href="javascript:bmUpdateConsent();"> Update my consent settings</a>`
## Events
The easiest way to see how events work is to view the `console.debug()` calls in the [demo](https://replete.github.io/biscuitman)
- `biscuitman:openModal`
- `biscuitman:closeModel`
- `biscuitman:buttonPress`
- `biscuitman:saveConsent`
- `biscuitman:scriptInjected`
- `biscuitman:scriptLoaded`
- `biscuitman:invalidateConsent`
- `biscuitman:updateConsent`
## Notes
This is a brand new pre-1.0 project and needs more testing and iteration, and isn't going to suit all circumstances yet, although I'm using it on live sites.
Expand Down

0 comments on commit e21adf5

Please sign in to comment.