@reform-digital/cookie-flow 1.3.8 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +798 -729
  2. package/package.json +24 -14
  3. package/prod/index.js +1 -1
package/README.md CHANGED
@@ -1,1047 +1,1116 @@
1
- _\*Proudly built with [Webflow DevKit](https://github.com/reform-digital/webflow-devkit)_
1
+ # CookieFlow™
2
2
 
3
- # Webflow DevKit™ – by Reform Digital®
3
+ ***
4
4
 
5
- ![DevKit Image](https://uploads-ssl.webflow.com/61700604b1b79e1cd9ef9412/6618f3d81b4b7e5a7b89c264_DevKit.png "Webflow DevKit")
5
+ <figure><img src="https://3948747524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyWDd0BQVjmRUYm47Xnrj%2Fuploads%2F3h17Hj5ZAxhUMFE6oHmg%2FThumb.png?alt=media&#x26;token=a7d697e2-d4cc-4310-a224-5f49fa4f3654" alt=""><figcaption></figcaption></figure>
6
6
 
7
- Webflow DevKit serves as a powerful template, employed by the development team at [Reform Digital®](https://reform.digital) - an award-winning Webflow agency and partner. Designed with a keen emphasis on upholding best practices and optimizing workflows, it aims to revolutionize web development processes. Specifically sculpted to complement Webflow development, this kit harmoniously integrates simplicity and efficiency, seeking to seamlessly embed them into your project lifecycle.
7
+ ***
8
8
 
9
- Before diving into development, please read through this documentation to familiarize yourself with the working structure of the template.
9
+ ## Overview
10
10
 
11
- ## Table of Contents
11
+ CookieFlow™ is a comprehensive cookie consent management solution developed by [Reform Digital®](https://reform.digital) specifically for Webflow websites. It provides a compliant, customizable framework for handling user consent preferences across different geographical regions, automatically adapting to privacy regulations like GDPR, CCPA, and others.
12
12
 
13
- - [Introduction](#introduction)
14
- - [Included Tools](#included-tools)
15
- - [Prerequisites](#prerequisites)
16
- - [Installation](#installation)
17
- - [Step 1: Setup Template](#step-1-setup-template)
18
- - [Step 2: Setup Public SSH Key](#step-2-setup-public-ssh-key-first-time-only)
19
- - [Step 3: Setup Private SSH Key](#step-3-setup-private-ssh-key-for-every-new-project)
20
- - [Step 4: Setup NPM](#step-4-setup-npm)
21
- - [Step 5: Setup Your Project](#step-5-setup-your-project)
22
- - [How to use DevKit](#how-to-use-devkit)
23
- - [Project Folders](#project-folders)
24
- - [Building & Testing in Development](#building-testing-in-development)
25
- - [Importing Scripts in Webflow](#importing-scripts-in-webflow)
26
- - [Building & Testing in Production](#building-testing-in-production)
27
- - [Shipping to NPM](#shipping-to-npm)
28
- - [Addressing Version Caching](#addressing-version-caching)
29
- - [Working with Branches & Contributing](#working-with-branches)
30
- - [Condensed Guide (for Existing DevKit Users)](#condensed-guide-for-existing-devkit-users)
13
+ **What CookieFlow™ Does**
31
14
 
32
- <a name="introduction"></a>
15
+ * **Automatically detects user location** and displays the appropriate consent banner
16
+ * **Manages cookie consent** across multiple categories (marketing, analytics, personalization)
17
+ * **Complies with regional regulations** (GDPR, CCPA, etc.)
18
+ * **Stores consent records** in your Supabase database for audit trails
19
+ * **Integrates seamlessly** with Google Tag Manager and Webflow Analytics
20
+ * **Respects privacy signals** like Do Not Track (DNT) and Global Privacy Control (GPC)
33
21
 
34
- ## 🏁 Introduction
22
+ ***
35
23
 
36
- The Webflow DevKit by Reform Digital® is more than just a tool—it represents a holistic approach to web development, offering a structured framework that aligns with the modern dynamics of the Webflow platform. Whether you're starting from scratch or integrating into an existing project, this template encapsulates a workflow optimized for efficiency, clarity, and scalability.
24
+ ### Features
37
25
 
38
- ### Workflow Overview
26
+ #### 🔍 Automatic Geolocation
39
27
 
40
- 1. **Local Development in Sync with GitHub:** Write and revise your code locally while maintaining version control through a synchronized GitHub repository. This enables collaborative work, easy version tracking, and a centralized source of truth for your project.
28
+ CookieFlow™ automatically detects your visitors' location using IP-based geolocation and displays the appropriate consent banner based on their region. If geolocation fails, it intelligently falls back to timezone-based detection.
41
29
 
42
- 2. **Testing via Local Server:** Before deploying any changes, test your code in real-time through a local server environment. This allows for rigorous debugging, performance analysis, and ensures the integrity of your code.
30
+ **How It Works:**
43
31
 
44
- 3. **Deploy to NPM:** Once you're satisfied with your local iterations, deploy your code to NPM. NPM serves as a reliable package manager, allowing you to manage and distribute your code efficiently.
32
+ 1. CookieFlow™ checks the visitor's IP address
33
+ 2. Determines their country code
34
+ 3. Matches the country to the appropriate zone (ZONE\_1, ZONE\_2, or ZONE\_3)
35
+ 4. Shows the correct banner for that region
36
+ 5. Hides banners for other regions
45
37
 
46
- 4. **Serve to Webflow via JsDelivr CDN:** By utilizing the JsDelivr CDN, your deployed code can be seamlessly integrated into your Webflow projects. This ensures fast delivery, high uptime, and optimal performance for your web applications.
38
+ **Privacy-Conscious:**
47
39
 
48
- 5. **Iterate, Version, and Scale:** The Webflow DevKit encourages iterative development. As your project grows, easily roll out new versions of your code. This modular approach ensures future maintenance, continuous scaling, and flexibility.
40
+ * IP addresses are anonymized before storage (last octet set to 0)
41
+ * Geolocation data is used only to determine compliance zone
42
+ * No personally identifiable information is collected during detection
49
43
 
50
- By leveraging the capabilities of this DevKit, developers can focus on what truly matters—the development process, while being assured that the underlying mechanics and workflows are robust, streamlined, and in tune with best practices.
44
+ #### 📍 Regional Compliance (3 Zones)
51
45
 
52
- <a name="included-tools"></a>
46
+ * **ZONE\_1 (Basic Notice)**: Simple notice-only approach for 130 countries with minimal compliance requirements
47
+ * **ZONE\_2 (Opt-Out/CCPA)**: For 6 CCPA-affected regions (US, PR, GU, AS, MP, VI) with "Do Not Sell" option
48
+ * **ZONE\_3 (Opt-In/GDPR)**: For 50 GDPR-affected regions (EU, UK, Canada, Brazil, Japan, etc.) with detailed consent options
49
+ * **Customizable**: Override defaults with script attributes if privacy regulations change
53
50
 
54
- ## 🛠️ Included Tools
51
+ #### Configurable Cookie Expiry
55
52
 
56
- - **[pnpm](https://pnpm.io/):** A fast, disk space-efficient package manager for installing code libraries.
53
+ Set how long consent cookies should last (default is 6 months). Users can be prompted to renew their consent when it expires.
57
54
 
58
- - **[esbuild](https://esbuild.github.io/):** An extremely fast JavaScript bundler and minifier, known for drastically reducing build times.
55
+ #### 📊 Consent Record Storage
59
56
 
60
- - **[Prettier](https://prettier.io/):** An opinionated code formatter that enforces a consistent style across your codebase by re-formatting code.
57
+ GDPR and other privacy regulations require consent records to be stored and maintained for audit trails. CookieFlow™ is built to work seamlessly with Supabase due to its ease of setup and free tier availability. Once configured, all consent records are automatically stored in your Supabase database, providing a complete compliance audit trail without additional maintenance.
61
58
 
62
- - **[ESLint](https://eslint.org/):** A tool for identifying and fixing problems in your JavaScript code with additional configurations for seamless integration with Prettier:
59
+ #### 🔒 Privacy Signal Respect
63
60
 
64
- - **[eslint-config-prettier](https://github.com/prettier/eslint-config-prettier):** Disables ESLint rules that might conflict with Prettier.
65
- - **[eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier):** Runs Prettier as an ESLint rule.
61
+ CookieFlow™ automatically respects and responds to:
66
62
 
67
- - **[javascript-obfuscator](https://github.com/javascript-obfuscator/javascript-obfuscator):** A tool for obfuscating JavaScript code, making it more difficult to understand and reverse engineer production code.
63
+ * Do Not Track (DNT) browser signals
64
+ * Global Privacy Control (GPC) signals
65
+ * Automatically opts users out if these signals are detected
68
66
 
69
- - **[chalk](https://github.com/chalk/chalk):** A tool that adds color and style to text in the command line, making it easier and more pleasant to read.
67
+ #### 🤖 Bot Detection
70
68
 
71
- - **[Express](https://expressjs.com/):** A tool for creating web servers through local host for real-time code testing.
69
+ Crawlers and bots won't see consent banners, keeping your site's SEO intact.
72
70
 
73
- - **[Inquirer](https://github.com/SBoudrias/Inquirer.js/):** A user interface library designed to streamline the deployment process. By presenting users with interactive checklists and guided questions, it negates the need for manual editing of scripts and JSON files, ensuring a smoother and more intuitive package setup.
71
+ #### 🔄 Consent ID Tracking
74
72
 
75
- - **[jQuery](https://jquery.com/):** A fast, small, and feature-rich JavaScript library designed to simplify tasks like HTML document traversal and manipulation, event handling, and animation. Webflow projects automatically include the jQuery library, enabling developers to utilize its functionalities without any additional setup. Recognizing this, Webflow DevKit seamlessly integrates support for jQuery syntax, without the need to import the library.
73
+ Tracks and displays a unique consent ID to users (GDPR requirement for EU visitors).
76
74
 
77
- <a name="prerequisites"></a>
75
+ #### 🎨 Fully Customizable
78
76
 
79
- ## ⚙️ Prerequisites
77
+ Complete control over styling and layout using Webflow's native design tools.
80
78
 
81
- Before utilizing this template, ensure the following software and environments are installed on your local machine:
79
+ ***
82
80
 
83
- - **[Visual Studio Code](https://code.visualstudio.com/):** A source-code editor that you'll use for writing and managing your code.
84
- - **[Node.js](https://nodejs.org/):** A JavaScript runtime to build and run your applications.
85
- - **[GitHub Desktop](https://desktop.github.com/):** (Optional, but recommended) A graphical interface that enables you to interact with GitHub without using the command line.
86
- - **[Google Chrome](https://www.google.com/chrome/):** A Chromium-based browser such as Google Chrome or Arc is required. Please note that this template is not compatible with Safari or some other browsers and may not function as intended if used with them.
81
+ ### Compliance
87
82
 
88
- ---
83
+ ✔ **Equal Prominence**: "Accept" and "Reject" buttons are identical in design.\
84
+ ✔ **No Pre-Checked Boxes**: Users must actively opt in to non-essential cookies.\
85
+ ✔ **Plain Language**: Simple, clear wording without legal jargon.\
86
+ ✔ **No Implied Consent**: Actions like scrolling or navigating do not count as consent.\
87
+ ✔ **No Cookie Walls**: Full access to the website is provided, even if cookies are rejected.\
88
+ ✔ **Granular Control**: Users can opt in to different cookie categories.\
89
+ ✔ **Close Button**: Clearly explains that no cookies will be set if closed.\
90
+ ✔ **Privacy & Cookie Policy Link**: Easily accessible for transparency.\
91
+ ✔ **Publisher Identification**: The website publisher's name is explicitly stated.\
92
+ ✔ **Stored Consent Choices**: Users' selections are remembered for a minimum of 6 months (per France & Italy).\
93
+ ✔ **Consent Expiry**: Re-consent required every 6–24 months, per country regulations.\
94
+ ✔ **Easy Consent Review**: Users can modify settings anytime via a widget or link.\
95
+ ✔ **Third-Party Cookies Disclosure**: Third-party providers are listed in the policy.\
96
+ ✔ **Cross-Site Tracking Compliance**: Explicit opt-in required for tracking across sites.\
97
+ ✔ **No Nudging**: Rejecting cookies is just as easy as accepting them.\
98
+ ✔ **Dismissal Transparency (Italy)**: Users are informed that rejecting cookies will not affect access to content.
89
99
 
90
- <a name="installation"></a>
100
+ CookieFlow™ has been built with these regulations in mind, for full compliance implement it according to the documentation, do not change its functionality and only edit and style it considering the above rules.
91
101
 
92
- # 🖥️ Installation
102
+ ### Considerations
93
103
 
94
- If you are an existing DevKit user, you can skip this detailed guide and view the [Condensed Guide](#condensed-guide-for-existing-devkit-users) instead.
104
+ While CookieFlow™ provides comprehensive cookie consent management, there are several Webflow-specific features that require additional attention to ensure full GDPR compliance:
95
105
 
96
- ## Step 1: Setup Template
106
+ #### Webflow E-Commerce is not GDPR compliant
97
107
 
98
- 1. **Create GitHub account**:
99
- - If you haven’t done so, [create a GitHub account](https://github.com/join).
100
- 2. **Clone this template**:
101
- - Navigate to the [main page](https://github.com/reform-digital/webflow-devkit) of the template repository.
102
- - Click on `Use this template` at the top of the repository and choose `Create a new repository`.
103
- - Ensure the "Owner" is your GitHub username, and give your repository a unique name relevant to the project (e.g., `client-project-name`).
104
- - Choose `Private` as the repository visibility.
105
- - Click on `Create repository` to generate your new repository.
106
- 3. **Download the Repository Locally Using GitHub Desktop**:
107
- - Navigate to your newly created GitHub repository (if not redirected there already upon creation).
108
- - Click on the `Code` button, and then choose `Open with GitHub Desktop`.
109
- - Follow the steps in GitHub Desktop to choose a folder on your local machine where the repository files will be downloaded and synchronized, and press `clone`.
110
- 4. **Launch Your Development Environment**:
111
- - In GitHub Desktop, check that your new repository is now listed under `Current Repository` and if not make sure to select it.
112
- - Click on the `Repository` tab in the top menu, and choose `Open in Visual Studio Code` or use the quick button link.
113
- - Visual Studio Code should launch, opening your project repository locally, ready for development.
108
+ Webflow's native e-commerce solution is not fully GDPR compliant by default, as it uses cookies that may track users without explicit consent. Since these cookies are managed directly by Webflow, our cookie consent solution, CookieFlow, cannot control or block them. If you are using Webflow e-commerce, we recommend consulting a legal expert and exploring additional compliance measures to ensure your store meets GDPR requirements.
114
109
 
115
- ### Understanding Steps 2 & 3 (SSH Key Configuration)
110
+ #### Webflow's native video element for YouTube
116
111
 
117
- When working on software projects, especially those that involve collaboration or automation, secure access to resources becomes paramount. A widely adopted method for securing this access is through **SSH (Secure SHell)** keys, a cryptographic system that facilitates encrypted communication between your computer and platforms like GitHub.
112
+ YouTube videos do not comply with GDPR regulations by default. To ensure users have control over their data, it's best to use embedded iFrames. If you add YouTube videos to your Webflow site using the native video element, personal data is automatically shared with YouTube and its parent company, Google, as soon as the page loads. To avoid this, consider using a custom code embed instead.
118
113
 
119
- SSH keys work in pairs: a `private key` and a `public key`. Upon generation, the private key remains on your computer and should be kept confidential. For certain automated workflows, like those in the Webflow DevKit template, the private key is required to be securely stored within the GitHub repository as a secret. This private key is always paired with its corresponding public key, which is stored in your general GitHub account settings. The public key's role is to recognize and trust incoming connections from your computer, ensuring authenticated access.
114
+ #### Webflow's map is not GDPR compliant
120
115
 
121
- For our specific use-case, we've incorporated **GitHub Actions** as our **Continuous Integration (CI)** and **Continuous Deployment (CD)** mechanism. This CI/CD mechanism handles tasks like automating version bumping and deploying production code to NPM, which can subsequently get served to your Webflow project via JsDelivr.
116
+ Webflow's native map element does not comply with GDPR regulations, as it automatically shares personal data with third parties like Google without user consent. To prioritize user privacy and provide better control over data sharing, it's advisable to use an embedded Google Map instead.
122
117
 
123
- The steps that follow will walk you through the generation of an `SSH key pair`, integrating it with your GitHub account for authentication, and then securely archiving the private key in your GitHub repository as a secret. This structured approach ensures both your project and GitHub Actions can securely liaise with vital resources on GitHub, eliminating the need for exposing direct login credentials.
118
+ #### Webflow's reCaptcha is not GDPR compliant
124
119
 
125
- ## Step 2: Setup SSH Key Pair & Public Key (First-Time Only)
120
+ Webflow's built-in reCaptcha does not fully comply with GDPR, as it collects user data (such as IP addresses and behavior) without explicit consent. To maintain compliance and safeguard user privacy, it's best to integrate reCaptcha manually into your forms.
126
121
 
127
- In this step, you'll generate an SSH key pair and add the public key to your GitHub account, enabling GitHub to recognize and trust communications from your computer. The good news is, once you've set this up, you won't have to repeat this step for future projects. It's a one-time configuration that benefits all your subsequent projects. To begin:
122
+ #### Remove `<noscript>` tags for compliance
128
123
 
129
- 1. **Open Terminal**:
124
+ `<noscript>` tags are not compliant with cookie consent regulations and should be removed. These tags execute even when JavaScript is disabled, which can bypass cookie consent mechanisms and potentially collect user data without proper authorization. To ensure GDPR compliance, it is essential to eliminate all `<noscript>` tags from your website.
130
125
 
131
- - Open a new terminal window within your Visual Studio Code session that contains your current project. You can achieve this by selecting `Terminal` from the main toolbar, followed by `New Terminal`. Alternatively, Mac users can use the `control`+`~` shortcut.
126
+ ***
132
127
 
133
- 2. **Check for Existing SSH Keys**:
128
+ ### Support
134
129
 
135
- - Before creating a new SSH key, it's important to check if you already have an existing key that you can use.
136
- - Open your terminal and execute the following command to see if existing SSH keys are present:
130
+ #### Getting Help
137
131
 
138
- ```sh
139
- ls -al ~/.ssh
140
- ```
132
+ Need assistance with CookieFlow™? Try these steps:
141
133
 
142
- - Look for files named `id_rsa.pub`, `id_ecdsa.pub`, or `id_ed25519.pub`. If such a file exists, you can skip Steps 3 & 4 below and proceed to add the key to GitHub (Step 5), **if you haven't already added it previously**.
134
+ 1. **Review the documentation** - Most common issues are covered in this guide
135
+ 2. **Check the browser console** - Look for error messages that may indicate configuration issues
136
+ 3. **Verify your configuration** - Ensure all attributes are spelled correctly and properly formatted
137
+ 4. **Validate Supabase credentials** - Confirm your Supabase URL and API key are correct and have proper permissions
138
+ 5. **Still stuck?** - Join our [Slack community](https://join.slack.com/t/rdcommunity/shared_invite/zt-2zser6sir-3CnFYB6gP4lvQsV2rY3wGw) for direct support from our team
143
139
 
144
- - If no existing keys are suitable, or if you prefer to create a new one, follow the steps below to generate a new SSH key pair.
140
+ #### Feature Requests & Bugs
145
141
 
146
- 3. **Generate SSH Key Pair**:
142
+ CookieFlow™ is actively maintained and continuously improved. We welcome your feedback:
147
143
 
148
- - Execute the following command in your terminal. Ensure the `email` you use matches the one registered on your GitHub account.
144
+ * **Feature requests** - Share ideas to make CookieFlow™ even better
145
+ * **Bug reports** - Help us identify and fix issues
146
+ * **General feedback** - Tell us about your experience
149
147
 
150
- ```sh
151
- ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
152
- ```
148
+ Join our [Slack community](https://join.slack.com/t/rdcommunity/shared_invite/zt-2zser6sir-3CnFYB6gP4lvQsV2rY3wGw) to contribute!
153
149
 
154
- - When **prompted**, it's advisable to opt for default settings and leave the passphrase empty for seamless deployment workflows. Adding a passphrase provides an extra layer of security, but it can introduce inconvenience. You'd be prompted to enter this passphrase each time you run deployment workflows. This could become tedious, especially if you revisit the project codebase after a prolonged period and potentially forget the passphrase.
150
+ ***
155
151
 
156
- 4. **Add SSH Key to the SSH-Agent**:
152
+ ## Recommended Setup
157
153
 
158
- - **For macOS/Linux:** Execute the following commands in your terminal:
154
+ ### Quick Start
159
155
 
160
- ```sh
161
- eval "$(ssh-agent -s)"
162
- ssh-add ~/.ssh/id_rsa
163
- ```
156
+ We provide a ready-to-use Webflow component that includes all necessary elements, attributes, and scripts out of the box. Simply copy the component from our demonstration website and paste it into your Webflow project.
164
157
 
165
- If you are using an existing key, replace id_rsa with the name of your existing private key file if it's different.
158
+ #### What's Included
166
159
 
167
- - **For Windows:** Utilize an SSH agent available through Git Bash, Cygwin, or another tool.
160
+ The prebuilt component comes with:
168
161
 
169
- 5. **Add SSH Key to GitHub Account**:
162
+ * **All required HTML elements** with proper attributes
163
+ * **The CookieFlow™ script** already integrated
164
+ * **Three banner variations** (for different compliance zones)
165
+ * **Settings/preferences modal** with consent toggles
166
+ * **Manager button** for reopening the consent interface
167
+ * **GDPR consent info banner**
170
168
 
171
- - Execute this command to automatically copy the **SSH Public Key** to your clipboard to minimise error:
169
+ #### Important: Script Configuration
172
170
 
173
- - **Mac**:
174
- ```sh
175
- cat ~/.ssh/id_rsa.pub | pbcopy
176
- ```
177
- If you are using an existing key, replace id_rsa with the name of your existing public key file if it's different.
178
- - **Manual Copying** (make sure to copy all contents after running command):
179
- ```sh
180
- cat ~/.ssh/id_rsa.pub
181
- ```
171
+ The prebuilt component includes the CookieFlow™ script already. You just need to:
182
172
 
183
- - Navigate to your GitHub account's SSH settings (`Profile icon` > `Settings` > `SSH and GPG keys`).
184
- - Click `New SSH key`, assign a descriptive `Title`, choose `Authentication key` under Key type, paste your copied public key under `Key`, and save it by pressing `Add SSH key`.
173
+ 1. Copy the component from our demo site
174
+ 2. Paste it into your Webflow project
175
+ 3. Update the script attributes in the component with your Supabase credentials (see the Supabase Setup section below)
176
+ 4. Customize the styling to match your brand
185
177
 
186
- ## Step 3: Setup Private SSH Key (For Every New Project)
178
+ ***
179
+
180
+ ### Supabase Setup
181
+
182
+ CookieFlow™ requires a Supabase database to store consent records for compliance and audit purposes. If you don't already have a Supabase account and database set up:
183
+
184
+ 1. **Sign up at** [**https://supabase.com**](https://supabase.com)
185
+ 2. **Create a new project** (wait for provisioning to complete)
186
+ 3. **Open the SQL Editor** in your Supabase dashboard
187
+ 4. **Paste & run the following SQL code** to create the necessary tables and security policies:
187
188
 
188
- Now, you'll securely store your SSH private key in the GitHub repository as a secret. This step is essential for enabling secure interactions between your project and the integrated CI/CD tools, allowing them to authenticate as if they were your computer.
189
+ ```sql
190
+ /* ============================================================
191
+ 1️⃣ CREATE TABLES
192
+ ============================================================ */
189
193
 
190
- 1. **Store SSH Key as GitHub Secret in the Repository**:
194
+ -- Create the main consents table (idempotent)
195
+ create table if not exists public.consents (
196
+ id serial primary key,
197
+ consent_id text not null,
198
+ anonymized_ip text,
199
+ action_date timestamptz default now(),
200
+ page_url text not null,
201
+ user_agent text,
202
+ consent_method text,
203
+ modal_text text,
204
+ button_clicked text,
205
+ consents jsonb not null,
206
+ geo_region text
207
+ );
191
208
 
192
- - Execute this command to automatically copy the **SSH Private Key** to your clipboard to minimise error:
193
- - **Mac:**
194
- ```sh
195
- cat ~/.ssh/id_rsa | pbcopy
196
- ```
197
- - **Manual Copying** (make sure to copy all contents including the **BEGIN** and **END** tags):
198
- ```sh
199
- cat ~/.ssh/id_rsa
200
- ```
201
- - Navigate to your new project repository on GitHub (the one where you cloned this template).
202
- - Go to the project `Settings`. Make sure you are in the project settings and not the global account settings accessed via your profile image.
203
- - In the sidebar menu under the `Security` section, click on the `Secrets and variables` dropdown, then choose `Actions`.
204
- - Click `New repository secret`.
205
- - Name it **`SSH_TOKEN`** (name must match this exactly) and paste the SSH private key content into the value field.
206
- - Click `Add secret` to finalize.
209
+ /* ============================================================
210
+ 2️⃣ ROW-LEVEL SECURITY (RLS)
211
+ ============================================================ */
207
212
 
208
- ## Step 4: Setup NPM
213
+ -- Enable RLS on the consents table
214
+ alter table public.consents enable row level security;
209
215
 
210
- 1. **Create a Free NPM Account:**
216
+ -- Allow anonymous INSERTs only (no SELECT/UPDATE/DELETE)
217
+ do
218
+ $$
219
+ begin
220
+ if not exists (
221
+ select 1
222
+ from pg_policies
223
+ where schemaname = 'public'
224
+ and tablename = 'consents'
225
+ and policyname = 'Allow public inserts'
226
+ ) then
227
+ create policy "Allow public inserts"
228
+ on public.consents
229
+ for insert
230
+ with check (true);
231
+ end if;
232
+ end
233
+ $$;
211
234
 
212
- - If not done so already, create a free [NPM account](https://www.npmjs.com/).
235
+ /* ============================================================
236
+ 3️⃣ QUERY HELPER FUNCTION
237
+ ============================================================ */
213
238
 
214
- 2. **(Optional) Create an NPM Organization:**
239
+ -- Use a wrapper so clients can only read whitelisted columns
240
+ create or replace function public.get_consent_by_id (p_consent_id text)
241
+ returns table (
242
+ consent_id text,
243
+ action_date timestamptz,
244
+ consents jsonb
245
+ )
246
+ language sql
247
+ stable
248
+ security definer
249
+ set search_path = public
250
+ as
251
+ $$
252
+ select consent_id, action_date, consents
253
+ from public.consents
254
+ where consent_id = p_consent_id
255
+ order by action_date desc
256
+ limit 1;
257
+ $$;
215
258
 
216
- - If you intend to manage your package under your own account/organization, you may **skip this step**.
217
- - If multiple owners or specific permissions for a project are required (e.g., for a client project), create a new NPM organization under your account.
218
- - Name it according to your client’s company or project name.
219
- - Grant your client permission to this organization whenever needed.
259
+ -- Revoke direct table SELECT, grant function EXECUTE
260
+ revoke select on public.consents from public;
261
+ grant execute on function public.get_consent_by_id(text) to public;
220
262
 
221
- 3. **Create an NPM Access Token:**
263
+ /* ============================================================
264
+ 4️⃣ HEARTBEAT FUNCTION (keep-alive for Supabase Free plan)
265
+ ============================================================ */
222
266
 
223
- - Click on your profile icon in NPM and select `Access Tokens`.
224
- - Generate a new `Classic Token`.
225
- - Name it descriptively, such as "Your-Project-Name NPM Token".
226
- - Select `Automation` type and click `Generate Token` to finish.
267
+ create or replace function public.heartbeat ()
268
+ returns void
269
+ language sql
270
+ stable
271
+ set search_path = public
272
+ as
273
+ $$
274
+ select 1;
275
+ $$;
227
276
 
228
- 4. **Copy Your NPM Token:**
277
+ -- Grant execution to the anonymous role so an external cron
278
+ -- can ping /rest/v1/rpc/heartbeat using only the anon key
279
+ grant execute on function public.heartbeat() to anon;
229
280
 
230
- - Ensure that the generated token is copied as it cannot be viewed again.
231
-
232
- 5. **Add the NPM Token as a GitHub Secret:**
233
- - Navigate to your new project repository on GitHub (the one you created by cloning this template).
234
- - Go to the project `Settings`, ensuring you are accessing project-specific settings (which are accessed via a link on the project toolbar), not global account settings (which are accessed via your profile icon).
235
- - In the sidebar menu under the `Security` section, select the `Secrets and variables` dropdown, then choose `Actions`.
236
- - Click `New repository secret`.
237
- - Name it **`NPM_TOKEN`** (name must match this exactly) and paste the NPM token into the value field.
238
- - Click `Add secret` to finalize.
239
-
240
- ## Step 5: Setup Your Project
241
-
242
- This section guides you through setting up your project package in Visual Studio Code, which involves installing a package manager, managing dependencies, and initial setup. Make sure you have the correct project and directory loaded in Visual Studio Code – you can always use GitHub desktop to load the correct repository (as you did in [Step 1.4](#step-1-setup-template)).
243
-
244
- 1. **Install pnpm (First-Time Only):**
245
-
246
- - pnpm is a fast, disk space efficient package manager. If it's your first time using pnpm, install it globally with the following command:
247
- ```sh
248
- npm install -g pnpm
249
- ```
250
-
251
- 2. **Install VS Code Extensions (First-Time Only):**
252
-
253
- - Install and activate [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) and [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extensions in Visual Studio Code.
254
-
255
- 3. **Install Dependencies:**
256
-
257
- - Execute the following command to install the project dependencies:
258
- ```sh
259
- pnpm install
260
- ```
261
-
262
- ### ✅ Installation Complete!
263
-
264
- ---
265
-
266
- <a name="how-to-use-devkit"></a>
267
-
268
- # 🚀 How to use DevKit
269
-
270
- Understanding the structure of the Webflow DevKit template is crucial for a seamless development experience.
271
-
272
- <a name="project-folders"></a>
273
-
274
- ## 📂 Project Folders
275
-
276
- Here’s a guide to help you navigate through the key directories and utilize them effectively:
277
-
278
- ### Source Directory
279
-
280
- The `src` folder serves as the primary workspace for your project, housing all the JavaScript files, CSS files, and modules necessary for your Webflow site.
281
-
282
- ### Files Folder
283
-
284
- Located within the src directory, the `files` folder is your primary working area designated for housing all your main JavaScript and CSS files for the project. For example `home.js`, `home.css`, `about.js`, `contact.js`, and so forth.
285
-
286
- Additionally, you can create any global files such as `global.js`, `global.css`, `analytics.js`, etc. in the same Files folder, if you wish to execute certain scripts or invoke specific modules across all pages of your website. The actual scope of each file (i.e. page-specific versus global) will depend on where it is imported in Webflow (see [Importing Scripts in Webflow](#importing-scripts-in-webflow)).
287
-
288
- ### Modules Folder
289
-
290
- Adjacent to the files folder, the `modules` directory is intended for smaller, reusable script segments. Examples of files you might store here include:
291
-
292
- - `greet.js`: A simple module to greet users.
293
- - `mirror-click.js`: A helper function to mirror click events in Webflow, useful across various sections and pages.
294
- - `animations.js`: A collection of animation functions to enhance your site's interactivity.
295
-
296
- These modular script files can be effortlessly imported into any of your page-specific script files. This practice not only keeps your codebase tidy but also fosters a modular development approach, making your code more maintainable and scalable.
297
-
298
- By adhering to this structure, you ensure a well-organized and efficient development environment, paving the way for a smoother integration of JavaScript functionalities and CSS styles into your Webflow projects.
299
-
300
- <a name="building-testing-in-development"></a>
301
-
302
- ## 🧑‍💻 Building & Testing in Development
303
-
304
- As you embark on the journey of developing JavaScript and CSS functionality within the "files" and "modules" directories, integrating testing into your workflow is paramount. Conducting tests in a development setting is imperative and should proceed hand-in-hand with the coding phase. To facilitate this, run a local development server and integrate your scripts into your Webflow staging domain. Stay alert for any anomalies or errors, utilizing the available debugging tools to rectify issues as they arise. This continuous loop of coding, testing, and debugging is crucial for cultivating a stable and trustworthy codebase.
305
-
306
- ### Running the Development Server
307
-
308
- To build and initiate the development server, execute:
309
-
310
- ```sh
311
- pnpm dev
281
+ /* Optional: Lock down visibility of heartbeat to everyone else */
282
+ revoke all on function public.heartbeat() from public;
312
283
  ```
313
284
 
314
- The development server facilitates **live reloading** on save, providing real-time feedback on your changes and significantly expediting the development and debugging processes.
315
-
316
- Furthermore, the development server is enhanced with **sourcemaps**, which are invaluable for debugging. Sourcemaps preserve the visibility of your initial code structure, even when inspecting your Webflow project. This feature is instrumental in tracing back to the origins of imported modules by referencing individual files, rather than navigating through bundled or minified code.
317
-
318
- If your project incorporates **multiple DevKit templates** and you intend to run several local servers simultaneously, it’s necessary to assign unique port numbers to each. To configure this:
285
+ 5. **Copy your Supabase URL and API Key** from your Supabase dashboard:
286
+ * **Project URL**: Found in **Settings → Data API** tab (e.g., `https://xxxxxxxxxxxxx.supabase.co`)
287
+ * **anon key**: Found in **Settings API Keys** tab (copy the `anon` `public` key)
319
288
 
320
- - Open the `server.js` file located in the `bin` folder.
321
- - Locate the line `const PORT = 3000;`.
322
- - Modify the port number (3000) to an alternative number (e.g., 3001) to distinguish each template’s local server.
289
+ ***
323
290
 
324
- By doing this, you enable the concurrent running of distinct local servers, each serving project files from a different template, all while avoiding port conflicts.
291
+ ### Script Configuration
325
292
 
326
- <a name="importing-scripts-in-webflow"></a>
293
+ The prebuilt component includes an embed element called "Component Scripts" with the required CookieFlow™ script already configured. To get started with the default configuration, simply update the script's attributes with your Supabase credentials (see [Supabase Setup](#-supabase-setup) above).
327
294
 
328
- ## ⤵️ Importing Scripts in Webflow
295
+ #### Basic Configuration
329
296
 
330
- DevKit offers **two methods** to import your JavaScript and CSS files into your Webflow project:
331
-
332
- ### 1️⃣ Traditional Method
333
-
334
- During the operation of a local server (via `pnpm dev` or `pnpm prod` mentioned later), DevKit conveniently logs the script tags for all JavaScript and CSS files situated in the src folder. These scripts, along with their imported modules and source maps, are subsequently exported to the dev folder and served directly from this location.
335
-
336
- **Logged script tags example:**
297
+ The script requires these two essential attributes to function:
337
298
 
299
+ ```html
300
+ <script
301
+ src="https://cdn.jsdelivr.net/npm/@reform-digital/cookie-flow@LATEST_VERSION/prod/index.js"
302
+ rd-consent-storage-url="https://your-project.supabase.co"
303
+ rd-consent-storage-api="your-api-key-here"
304
+ ></script>
338
305
  ```
339
- === JS Scripts: === (Before </body> tag)
340
306
 
341
- <script src="http://localhost:3000/about.js" defer></script>
307
+ #### Advanced Configuration (Optional)
342
308
 
343
- <script src="http://localhost:3000/global.js" defer></script>
309
+ Beyond the basic setup, CookieFlow™ supports additional customizations to meet your specific compliance needs and preferences.
344
310
 
345
- <script src="http://localhost:3000/home.js" defer></script>
311
+ **Cookie Expiration Configuration**
346
312
 
347
- === CSS Scripts: === (Inside <head> tag)
313
+ **Default Behavior**: By default, the consent cookie expires after **6 months**. This setting works well for most countries and aligns with common GDPR requirements.
348
314
 
349
- <link rel="stylesheet" href="http://localhost:3000/home.css">
350
- ```
315
+ **How It Works**: CookieFlow™ stores a consent cookie called `cookieconsent_status` that remembers the user's choices. The expiration of this cookie is controlled by the `rd-consent-expiry` attribute in your script tag.
351
316
 
352
- Integration steps:
317
+ **Setting a Custom Expiration**: If you need to set a different expiration period based on your specific country's GDPR regulations, you can override the default by adding the `rd-consent-expiry` attribute to your script tag along with a value in **months**. For example, if your country states that consents should expire after 3 months instead of six, then you would update the attribute as follows:
353
318
 
354
- 1. **Page Styles:** Manually copy the required `<link>` tag/s and paste them into the designated Webflow page, inside the `<head>` tag.
355
- 2. **Page Scripts:** Manually copy the required `<script>` tag/s and paste them into the designated Webflow page, either before the closing `</body>` tag or inside the `<head>` tag (thanks to the defer attribute, both options work seamlessly).
356
- 3. **Global Styles:** For styles intended to be global, add the respective `<link>` tag/s in the Webflow site’s global settings, insice the `<head>` tag.
357
- 4. **Global Scripts:** For scripts intended to be global, add the respective `<script>` tag/s in the Webflow site’s global settings, either in the closing `</body` tag or the `head` tag (thanks to defer).
358
-
359
- ⚠️ **Inefficiency of Traditional Method:** Transitioning from development to production necessitates manually replacing these script tags with their production counterparts, and reverting back for subsequent changes — a process that can become cumbersome over time. To address this shortfall, DevKit offers an improved automated method which handles the swtiching of the tags for you:
360
-
361
- ### 2️⃣ Automated Method (Recommended)
362
-
363
- - Jump to [condensed version](#importing-scripts-in-webflow2) (experienced DevKit users)
364
-
365
- DevKit offers a custom script import mechanism designed to streamline and automate the process of integrating JavaScript and CSS into your Webflow project. This approach eliminates the need for manual switching between script tags when moving from a development to a production environment, providing a smoother and more efficient workflow.
366
-
367
- ### Setup
368
-
369
- **`Step 1` Main Settings:**
370
-
371
- Add this script to your site’s **global** settings in the **`<head>`** tag. The script is designed to configure essential variables for your project: the path to your npm package, the development mode toggle, and the local port number. These variables are crucial for script loader functions and other development processes across your site.
372
-
373
- ```
374
- <!-- RD® Webflow DevKit / Main Settings -->
375
- <script>
376
- window.npmPath = "@reform-digital/sample-project@1.0.0"; // Update this once you have shipped to npm.
377
- window.devMode = true; // Change to false in production
378
- window.classViewer = true; // Helper to display classes and ids in DevMode
379
- window.localPort = 3000; // Also change in bin/localport.js in VS Code
380
- </script>
319
+ ```html
320
+ <script
321
+ src="https://cdn.jsdelivr.net/npm/@reform-digital/cookie-flow@LATEST_VERSION/prod/index.js"
322
+ rd-consent-storage-url="https://your-project.supabase.co"
323
+ rd-consent-storage-api="your-api-key-here"
324
+ rd-consent-expiry="3"
325
+ ></script>
381
326
  ```
382
327
 
383
- **_Main Settings Configurations:_**
328
+ **What Happens on Expiry**: When the consent cookie expires:
384
329
 
385
- - **NPM Path:** The Main Settings script includes a default `npmPath` that serves as a placeholder during the development phase. Initially, the template is configured to bypass this sample project path, so there's no immediate need to alter it during development. Once your project is ready for deployment and you've published your package to npm, you should update the `npmPath` variable to your own npm package path "@your-npm-username/your-package-name@version" to auto-direct the script and style loaders to your live production files via jsDelivr.
386
- - **Dev Mode:** The `devMode` variable is a boolean that controls whether the development mode is active (**true**) or inactive (**false**). When `devMode` is `true` (development mode), the integrated script-loader and style-loader will first check for a local server instance initiated by either `pnpm dev` or `pnpm prod` within VS Code. If a local server is found, it serves the site files directly from there, allowing for real-time testing and development—this local version is only visible to you, while other visitors continue to access the production files. In the absence of a local server, the loaders will fall back to the production version, fetching files via jsDelivr. Furthermore, devMode enables detailed console logging for both local and npm file requests, aiding in the debugging process and clarifying which file sources are being rendered in your local browser. Conversely, when `devMode` is set to `false`, it signifies that the site is in its production phase. The loaders will then bypass the local server check and directly load files from npm to optimize performance. Console logs related to devMode activities are also disabled in production mode to maintain a clean and performance-focused environment.
387
- - **Class Viewer:** The `classViewer` variable is a toggle (set to **true** to enable, or **false** to disable) that controls the Class Viewer widget during Dev Mode. This widget is a convenient tool designed to streamline the process of identifying element IDs and class names within the DOM. It eliminates the need to switch back to Webflow for this information, enhancing efficiency. When activated, simply clicking on any DOM element will bring up a modal that showcases the selected element's full hierarchy, including its parents, along with their respective classes and IDs. In cases where classes or IDs are absent, plain HTML tags are displayed. Moreover, clicking on any displayed tag automatically copies its class name, ID, or HTML tag to your clipboard, facilitating quick and easy referencing.
388
- - **Local Port:** The `localPort` setting specifies the port number on which your local server is running. The default port is **3000** but can be altered to suit your needs, such as when running multiple local servers simultaneously. Adjust the `localPort` value in the main settings to your preferred port to direct the script-loader and style-loader to the correct local server. Ensure this change is also mirrored in the Webflow DevKit template within VS Code by modifying the file at `/bin/localport.js` to match otherwise the template will not connect accordingly.
330
+ 1. User returns to your site
331
+ 2. CookieFlow™ detects the expired cookie
332
+ 3. The appropriate consent banner is shown again
333
+ 4. User can reconfirm or change their preferences
389
334
 
390
- **`Step 2` Style Loader:**
335
+ **Displaying Expiry Date to Users (Optional)**: To inform users when their consent expires, add this attribute to any text element:
391
336
 
392
- Add this script to your site’s **global** settings in the **`<head>`** tag. It enables the dynamic loading of styles based on the development server’s status.
393
-
394
- ```
395
- <!-- RD® Webflow DevKit / Style Loader -->
396
- <script src="https://cdn.jsdelivr.net/npm/@reform-digital/webflow-devkit-utils@1.1.0/prod/style-loader.js"></script>
337
+ ```html
338
+ <!-- Will render as "6 months" (based on your configuration) -->
339
+ <p><span rd-cookieflow="consent-expiry">{0}</span> months</p>
397
340
  ```
398
341
 
399
- **`Step 3` Script Loader:**
400
-
401
- Add this script to your site’s **global** settings before the **`</body>`** closing tag. It enables the dynamic loading of scripts based on the development server’s status.
342
+ CookieFlow™ will automatically replace `{0}` with the expiry period from your script configuration.
402
343
 
403
- ```
404
- <!-- RD® Webflow DevKit / Script Loader -->
405
- <script src="https://cdn.jsdelivr.net/npm/@reform-digital/webflow-devkit-utils@1.1.0/prod/script-loader.js"></script>
406
- ```
344
+ **Regional Compliance Overview**
407
345
 
408
- ### Import Files
346
+ CookieFlow™ automatically adapts to your visitors' location, showing the appropriate compliance interface. The system uses three compliance zones:
409
347
 
410
- **`Global` Styles:**
348
+ **ZONE\_1: Basic Notice (Default)**
411
349
 
412
- If you have any global CSS files that should be loaded across all pages, import them by adding the following script to your site’s **global** settings in the **`<head>`** tag, under the Style Loader script. Add and remove file names as required (the globalStyles variable is a comma-separated array).
413
-
414
- ```
415
- <!-- RD® Webflow DevKit / Global Styles -->
416
- <script>
417
- const globalStyles = ["global.css", "animation.css"];
418
- loadWebflowStylesheets(globalStyles, npmPath);
419
- </script>
420
- ```
350
+ **Countries**: Most countries worldwide\
351
+ **Behavior**: Simple notice informing users about cookie usage\
352
+ **User Actions**: Accept or dismiss the notice\
353
+ **Use Case**: Minimal compliance requirements
421
354
 
422
- **`Global` Scripts:**
355
+ **Default Country Assignment** (130 countries): AF, AX, AL, DZ, AD, AO, AI, AQ, AG, AM, AW, AU, AZ, BS, BD, BB, BY, BZ, BJ, BM, BT, BO, BQ, BA, BW, BV, IO, BN, BF, BI, CV, KH, CM, KY, CF, TD, CL, CN, CX, CC, CO, KM, CG, CD, CK, CR, CI, CU, CW, DJ, DM, DO, EC, EG, SV, GQ, ER, SZ, ET, FK, FO, FJ, GF, PF, TF, GA, GM, GE, GH, GI, GL, GD, GP, GT, GG, GN, GW, GY, HT, HM, VA, HN, HK, IN, ID, IR, IQ, IM, JM, JE, JO, KZ, KI, KP, KW, KG, LA, LB, LS, LR, LY, MO, MG, MW, MY, MV, ML, MH, MQ, MR, YT, MX, FM, MD, MC, MN, ME, MS, MA, MZ, MM, NA, NR, NP, NC, NI, NE, NU, NF, MK, OM, PK, PW, PS, PA, PG, PY, PE, PH, PN, RE, RU, RW, BL, SH, KN, LC, MF, PM, VC, WS, SM, ST, SA, SN, RS, SC, SL, SG, SX, SB, SO, GS, SS, LK, SD, SR, SJ, SY, TW, TJ, TZ, TH, TL, TG, TK, TO, TT, TN, TM, TC, TV, UZ, UA, AE, VU, VE, VN, VG, WF, UM, EH, YE, ZM, ZW
423
356
 
424
- If you have any global JavaScript files that should be loaded across all pages, import them by adding the following script to your site’s **global** settings before the **`</body>`** closing tag, under the Script Loader script. Add and remove file names as required (the globalScripts variable is a comma-separated array).
357
+ **ZONE\_2: Opt-Out (CCPA)**
425
358
 
426
- ```
427
- <!-- RD® Webflow DevKit / Global Scripts -->
428
- <script>
429
- const globalScripts = ["global.js", "analytics.js"];
430
- loadWebflowScripts(globalScripts, npmPath);
431
- </script>
432
- ```
359
+ **Countries**: United States and other CCPA-affected regions\
360
+ **Behavior**: Users must opt-out if they don't want their data sold\
361
+ **User Actions**:
433
362
 
434
- **`Page` Styles:**
363
+ * Accept All
364
+ * Reject All (opt-out)
365
+ * Manage Preferences (opens settings) **Use Case**: California Consumer Privacy Act (CCPA) compliance
435
366
 
436
- If you have any page-specific CSS files that should be loaded on a specific page, import them by adding the following script to your **page** settings in the **`<head>`** tag.
367
+ **Default Country Assignment** (6 countries): AS, GU, MP, PR, US, VI
437
368
 
438
- ```
439
- <!-- RD® Webflow DevKit / Page Styles -->
440
- <script>
441
- const pageStyles = ["home.css"];
442
- loadWebflowStylesheets(pageStyles, npmPath);
443
- </script>
444
- ```
369
+ **Special Features**:
445
370
 
446
- For the About page for example, if you have created an `about.css` in your src folder, you would replace `const pageStyles = ["home.css"];` with `const pageStyles = ["about.css"];`
371
+ * "Do Not Sell My Personal Information" option
447
372
 
448
- **`Page` Scripts:**
373
+ **ZONE\_3: Opt-In (GDPR)**
449
374
 
450
- If you have any page-specific JavaScript files that should be loaded on a specific page, import them by adding the following script to your **page** settings before the **`</body>`** closing tag.
375
+ **Countries**: European Union and other GDPR-affected regions\
376
+ **Behavior**: Granular consent required for each cookie category\
377
+ **User Actions**:
451
378
 
452
- ```
453
- <!-- RD® Webflow DevKit / Page Scripts -->
454
- <script>
455
- const pageScripts = ["home.js"];
456
- loadWebflowScripts(pageScripts, npmPath);
457
- </script>
458
- ```
379
+ * Accept All
380
+ * Reject All
381
+ * Accept Selected (only enable desired categories)
382
+ * Open detailed preferences **Use Case**: General Data Protection Regulation (GDPR) compliance
459
383
 
460
- For the About page for example, if you have created an `about.js` in your src folder, you would replace `const pageScripts = ["home.js"];` with `const pageScripts = ["about.js"];`
384
+ **Default Country Assignment** (50 countries): AR, AT, BH, BE, BR, BG, CA, HR, CY, CZ, DK, EE, FI, FR, DE, GR, HU, IS, IE, IL, IT, JP, KE, KR, LV, LI, LT, LU, MT, MU, NL, NZ, NG, NO, PL, PT, QA, RO, SK, SI, ZA, ES, SE, CH, TR, UG, GB, UY
461
385
 
462
- ### How It Works
386
+ **Special Features**:
463
387
 
464
- Once you have shipped your production files to npm (see [Shipping to NPM](#shipping-to-npm)) and updated the `npmPath` in the global script, the script loader automatically loads your production files located in npm via jsDelivr.
388
+ * Detailed cookie category descriptions
389
+ * Consent ID display for audit trails
390
+ * Granular consent management
465
391
 
466
- When you're ready to test new changes, running a local development server using `pnpm dev` (or a production testing server using `pnpm prod` as oulined in next section) triggers the script loader to temporarily deactivate the live production scripts from npm on your local browser. This enables you to seamlessly work and test in a local environment without affecting what the public sees on your live website.
392
+ **Automatic Detection**
467
393
 
468
- This transition is seamless and requires no manual intervention, allowing you to focus on development and testing without worrying about the underlying script management. Once you're done and shut down your local server, your browser automatically reverts to serving the live production files, ensuring a consistent and error-free user experience.
394
+ CookieFlow™ uses a two-step detection process:
469
395
 
470
- By adopting the Automated Method with DevKit’s custom script import mechanism, you are choosing a workflow that is not only more efficient but also less prone to human error, ensuring a smoother development experience and a more reliable live website.
396
+ 1. **Primary**: IP-based geolocation (via ipapi.co)
397
+ 2. **Fallback**: Timezone-based detection if IP lookup fails
471
398
 
472
- <a name="building-testing-in-production"></a>
399
+ You don't need to configure anything for this to work—it's automatic.
473
400
 
474
- ## 🧑‍💻 Building & Testing in Production
401
+ **Regional Configuration Override**
475
402
 
476
- When your files and modules have been extensively tested and are stable in the development environment, it’s time to shift your focus to the production environment for further testing and validation.
403
+ By default, CookieFlow™ uses predefined country assignments based on current privacy regulations (see the [Regional Compliance Overview](#regional-compliance-overview) above). However, you can override these defaults if:
477
404
 
478
- ### Running the Production Server
405
+ 1. A country's privacy regulations change
406
+ 2. You need to customize the regional assignments for your specific use case
407
+ 3. You want to test different compliance zones
479
408
 
480
- To assess your code’s performance and security in a production-like setting, execute:
409
+ To customize country assignments, add these attributes to your script tag:
481
410
 
482
- ```sh
483
- pnpm prod
411
+ ```html
412
+ <script
413
+ src="https://cdn.jsdelivr.net/npm/@reform-digital/cookie-flow@LATEST_VERSION/prod/index.js"
414
+ rd-consent-storage-url="https://your-project.supabase.co"
415
+ rd-consent-storage-api="your-api-key-here"
416
+ rd-zone-1="US,CA,MX"
417
+ rd-zone-2="UK,AU,BR"
418
+ rd-zone-3="DE,FR,IT,ES"
419
+ ></script>
484
420
  ```
485
421
 
486
- Executing this command will bundle, minify, and obfuscate your code, aiming to boost performance and security. It’s crucial to note that the production server does not support live reloading. This is a deliberate design choice, as the production environment is not intended for real-time code adjustments. Instead, its primary purpose is to confirm that the production files are correctly bundled and to validate that they function as expected before being deployed to NPM for live production use.
487
-
488
- ### Building Without Running a Server
422
+ **How to Override**: Simply provide a comma-separated list of 2-letter ISO country codes to reassign any country to a different zone.
489
423
 
490
- For scenarios where you wish to build the production files without launching the production server, utilize:
424
+ **Example**: If Canada moves from ZONE\_3 to ZONE\_2 due to a regulation change:
491
425
 
492
- ```sh
493
- pnpm build
426
+ ```html
427
+ <script
428
+ ...
429
+ rd-zone-2="CA"
430
+ ></script>
494
431
  ```
495
432
 
496
- Ensuring the built files function properly in a production-like setting is essential. This step verifies their performance and readiness for deployment, confirming that they are fully prepared for live production use.
433
+ **Configuration Attribute Reference**
497
434
 
498
- <a name="shipping-to-npm"></a>
435
+ **`rd-consent-storage-url` (Required)**
499
436
 
500
- ## 🚀 Shipping to NPM
437
+ * Your Supabase project URL
438
+ * Format: `https://xxxxxxxxxxxxx.supabase.co`
439
+ * Found in: Settings → Data API
501
440
 
502
- After thorough development and testing of your code in both the development and production environments, the next pivotal step is to ship your code to NPM. This is a crucial phase as it involves packaging your code and making it accessible for live production use. We've built a seamless mechanism for shipping your code to NPM.
441
+ **`rd-consent-storage-api` (Required)**
503
442
 
504
- ### Update the README.md File
443
+ * Your Supabase anonymous/public API key
444
+ * Format: Long string of characters
445
+ * Found in: Settings → API Keys (use the `anon` `public` key)
505
446
 
506
- Before running the ship command, ensure you have updated the README.md file. If this is not done, then the current DevKit README, which you are reading now, will be added to NPM. This could create confusion as it does not provide information specific to your package or project. Instead, your README should clearly outline the purpose, installation, usage, and any other important details related to your package or project.
447
+ **`rd-consent-expiry` (Optional)**
507
448
 
508
- ### Run the Ship Command
449
+ * Cookie expiration duration in months
450
+ * Default: `6` (6 months)
451
+ * Can be any number (e.g., `3`, `12`, `24`)
509
452
 
510
- To build and initiate the development server, execute:
453
+ **`rd-zone-1`, `rd-zone-2`, `rd-zone-3` (Optional)**
511
454
 
512
- ```
513
- pnpm ship
514
- ```
515
-
516
- Note: If you are using the GitHub extension for VS Code, you might receive the message "GitHub for VS Code is requesting additional permissions”. If so, review the permissions requested by the app and grant the necessary permissions.
455
+ * Comma-separated list of country codes (2-letter ISO format)
456
+ * Used to override default regional assignments
457
+ * Format: `"US,CA,MX"`
517
458
 
518
- ### Pre-shipment Checklist
459
+ ***
519
460
 
520
- Executing the `pnpm ship` command starts a 9-step pre-shipment checklist. It ensures that the NPM destination, package description, change type (major, minor, patch), and other package details are correctly set.
461
+ ### Store Consents
521
462
 
522
- The script will interactively guide you through the following:
463
+ CookieFlow™ automatically stores comprehensive consent records in your Supabase database for compliance and audit purposes. Each time a user interacts with the consent banner, a detailed record is created that includes both technical metadata and the user's specific consent choices.
523
464
 
524
- - Confirming the destination package name. You can edit it if necessary.
525
- - Confirming the package description. Again, you can edit this if required.
526
- - Confirming the author. Similarly, you can edit this if required.
527
- - Confirming the package keywords. Again, you can edit or omit this if required.
528
- - Confirming the license type. Similarly, you can edit this if required.
529
- - Choosing the type of version update (patch, minor, major). For initial shipments, the version will be set to 1.0.0.
530
- - Describing the changes in this version, which will be appended to the CHANGELOG.md file.
531
- - Confirming that the README.md file has been updated.
532
- - Final confirmation before proceeding.
465
+ #### What Information is Stored
533
466
 
534
- After you confirm, the script will:
467
+ Every consent record contains the following information:
535
468
 
536
- - Update the package.json with the new version, name, description, and authors.
537
- - Check if the version tag exists locally or remotely and handle it.
538
- - Commit the changes and tag the commit with the new version.
539
- - Trigger the CI/CD Pipeline.
469
+ **Consent Identification**
540
470
 
541
- ### CI/CD Pipeline
471
+ * **`consent_id`**: Unique identifier generated from timestamp and anonymized IP (28-character base36 string)
472
+ * **`action_date`**: Precise timestamp when consent was given (automatically set by database)
542
473
 
543
- - **Bundling and Optimization:** The CI/CD pipeline automates the process of bundling your code. It applies necessary optimizations and minifications.
544
- - **GitHub Push:** The code, along with its shipment settings and the updated version number, is then pushed to your GitHub repository.
545
- - **GitHub Action - Ship to NPM:** After the push to GitHub, a predefined GitHub Action is triggered. This action ensures your package is correctly published under your NPM account. It handles tasks like authentication with NPM and publishing.
474
+ **User Consent Choices**
546
475
 
547
- ### Post-Shipment Steps
476
+ * **`consents`**: JSON object containing the user's specific consent decisions:
548
477
 
549
- After successful shipment to NPM, depending on the script tag import method you've set up in your Webflow project (see [Importing Scripts in Webflow](#importing-scripts-in-webflow)), follow the steps below:
478
+ ```json
479
+ {
480
+ "marketing": true/false,
481
+ "analytics": true/false,
482
+ "personalization": true/false,
483
+ "essential": true
484
+ }
485
+ ```
550
486
 
551
- #### Automated Method (Recommended):
487
+ **Technical Metadata**
552
488
 
553
- Update npmPath: In your Webflow project, locate the DevKit "Main Settings" script in global `<head>` section. Update the npmPath variable with your shipped NPM package path:
489
+ * **`anonymized_ip`**: User's IP address with the last octet set to "0" for privacy
490
+ * **`user_agent`**: Browser and device information for technical support
491
+ * **`page_url`**: The website domain where consent was given
492
+ * **`geo_region`**: User's compliance zone (ZONE\_1, ZONE\_2, or ZONE\_3)
554
493
 
555
- ```
556
- const npmPath = "@your-npm-username/your-package-name@version";
557
- ```
494
+ **User Interaction Details**
558
495
 
559
- This directs the script loader to fetch the production files directly from your NPM package when DevMode is off (set to "false") during production. When DevMode is on (set to "true") during development, the script loader tries to load the scripts from your local development server when active and auto-switches to your NPM files when the local server is off. Replace `@your-npm-username/your-package-name@version` with the appropriate values. While you can omit @version to always fetch the latest version of the script, doing so may lead to caching issues if the CDN or browsers cache an older version of the script. Specifying the exact version helps to ensure that users always receive the correct version of your script. Refer to [Addressing Version Caching](#addressing-version-caching) for ways to mitigate these issues.
496
+ * **`consent_method`**: How consent was given ("accept\_all", "reject\_all", "accept\_selected")
497
+ * **`button_clicked`**: Text content of the specific button the user clicked
498
+ * **`modal_text`**: The full text content of the consent banner/modal
560
499
 
561
- #### Traditional Method:
500
+ #### Consent Record Examples
562
501
 
563
- If you're using the traditional method for script tags in Webflow, update your script tags to the following format:
502
+ **Example 1: Accept All (GDPR Region)**
564
503
 
565
- ```
566
- <script src="https://cdn.jsdelivr.net/npm/@your-npm-username/your-package-name@version/your-filename.js"></script>
504
+ ```json
505
+ {
506
+ "consent_id": "A1B2C3D4E5F6G7H8I9J0K1L2M3N4",
507
+ "action_date": "2024-01-15T14:30:25.123Z",
508
+ "anonymized_ip": "192.168.1.0",
509
+ "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
510
+ "page_url": "https://example.com",
511
+ "consent_method": "accept_all",
512
+ "button_clicked": "Accept All",
513
+ "modal_text": "We use cookies to enhance your experience...",
514
+ "geo_region": "ZONE_3",
515
+ "consents": {
516
+ "marketing": true,
517
+ "analytics": true,
518
+ "personalization": true,
519
+ "essential": true
520
+ }
521
+ }
567
522
  ```
568
523
 
569
- And your CSS files to:
524
+ **Example 2: Selective Consent (GDPR Region)**
570
525
 
526
+ ```json
527
+ {
528
+ "consent_id": "B2C3D4E5F6G7H8I9J0K1L2M3N4O5",
529
+ "action_date": "2024-01-15T14:35:10.456Z",
530
+ "anonymized_ip": "203.45.67.0",
531
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
532
+ "page_url": "https://example.com",
533
+ "consent_method": "accept_selected",
534
+ "button_clicked": "Save Preferences",
535
+ "modal_text": "We use cookies to enhance your experience...",
536
+ "geo_region": "ZONE_3",
537
+ "consents": {
538
+ "marketing": false,
539
+ "analytics": true,
540
+ "personalization": false,
541
+ "essential": true
542
+ }
543
+ }
571
544
  ```
572
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@your-npm-username/your-package-name@version/your-filename.css">
573
- ```
574
-
575
- Replace `@your-npm-username/your-package-name@version/your-filename.js` or `.css` with the appropriate values. While you can omit @version to always fetch the latest version of the script, doing so may lead to caching issues if the CDN or browsers cache an older version of the script. Specifying the exact version helps to ensure that users always receive the correct version of your script. Refer to [Addressing Version Caching](#addressing-version-caching) for ways to mitigate these issues.
576
-
577
- ### Verification
578
545
 
579
- To ensure everything is in order:
546
+ **Example 3: Reject All (CCPA Region)**
580
547
 
581
- - Visit your live website.
582
- - Open your browser's developer tools and inspect the network requests.
583
- - Confirm that the JavaScript and CSS files are being sourced from jsDelivr.
548
+ ```json
549
+ {
550
+ "consent_id": "C3D4E5F6G7H8I9J0K1L2M3N4O5P6",
551
+ "action_date": "2024-01-15T14:40:15.789Z",
552
+ "anonymized_ip": "198.51.100.0",
553
+ "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15",
554
+ "page_url": "https://example.com",
555
+ "consent_method": "reject_all",
556
+ "button_clicked": "Reject All",
557
+ "modal_text": "We use cookies to enhance your experience...",
558
+ "geo_region": "ZONE_2",
559
+ "consents": {
560
+ "marketing": false,
561
+ "analytics": false,
562
+ "personalization": false,
563
+ "essential": true
564
+ }
565
+ }
566
+ ```
584
567
 
585
- <a name="addressing-version-caching"></a>
568
+ #### Privacy & Security Features
586
569
 
587
- ## 🔄 Addressing Version Caching
570
+ **IP Anonymization**
588
571
 
589
- When deploying updates to your scripts via NPM and serving them through jsDelivr for your Webflow project, understanding how versioning and caching work together is crucial to ensure that your users always receive the latest version of your scripts.
572
+ * All IP addresses are automatically anonymized by setting the last octet to "0"
573
+ * Example: `192.168.1.123` becomes `192.168.1.0`
574
+ * This provides location data while protecting user privacy
590
575
 
591
- ### Using @latest for Versioning
576
+ **Unique Consent IDs**
592
577
 
593
- If you choose to use the @latest tag (or omit the version number altogether), you are instructing jsDelivr to serve the latest version of your script. This is perfectly fine for your initial release, however, for subsequent version releases, this approach can lead to caching challenges:
578
+ * Each consent record gets a unique 28-character identifier
579
+ * Generated using SHA-256 hash of timestamp + anonymized IP
580
+ * Enables tracking consent changes over time while maintaining privacy
594
581
 
595
- - **CDN Caching:** jsDelivr, like other CDNs, caches content across its global network of servers to reduce latency and improve performance. When a new version of your script is published, it might take some time for the CDN to update the cached content across all of its servers.
596
- - **Browser Caching:** Browsers also cache content locally to improve page load times. If a user has recently visited your site, their browser might have cached the old version of your script, and it could take some time before the browser checks for an updated version.
582
+ **Database Security**
597
583
 
598
- ### Manually Purging CDN Cache
584
+ * Row-level security (RLS) enabled on all tables
585
+ * Anonymous users can only INSERT records (no SELECT/UPDATE/DELETE)
586
+ * Consent retrieval requires specific function calls with proper permissions
599
587
 
600
- To expedite the process of updating cached content on jsDelivr, you can manually purge the cache for your script files. Visit [jsDelivr’s Purge Tool](https://www.jsdelivr.com/tools/purge) and enter the URLs of your script files to clear the cache. However, this process can be time-consuming, especially if you have multiple script files, and it only addresses CDN caching—not browser caching.
588
+ #### Compliance Benefits
601
589
 
602
- ### Manually Clearing Browser Cache
590
+ **Audit Trail**
603
591
 
604
- While you can clear your own browser's cache or perform a hard reset (Shift + Refresh) to fetch the latest version of your scripts (provided that the CDN cache has already been resolved or purged), there is no simple way to force this action on your visitors' browsers. If they have visited your site recently and have a cached version of your scripts, they might not see the updates until their browser's cache expires and fetches the new version.
592
+ * Complete record of all consent decisions
593
+ * Timestamped entries for regulatory compliance
594
+ * Detailed interaction metadata for transparency
605
595
 
606
- ### Using Specific Versions to Avoid Caching Issues
596
+ **Data Subject Rights**
607
597
 
608
- To circumvent both CDN and browser caching issues, the recommended approach is to use specific version numbers in your imported script tags:
598
+ * Users can request their consent records using their consent ID
599
+ * Records can be exported for data portability requests
600
+ * Clear consent withdrawal tracking
609
601
 
610
- - In the Automated script import method (recommended), under `npmPath` you would add `"@your-npm-username/your-package-name@version"`
611
- - In the Traditional script import method, for each script tag `src` you would add `"https://cdn.jsdelivr.net/npm/@your-npm-username/your-package-name@version/your-filename.js"`
612
- - Similarly, for each style tag `href` you would add `"https://cdn.jsdelivr.net/npm/@your-npm-username/your-package-name@version/your-filename.css"`.
602
+ **Regulatory Reporting**
613
603
 
614
- By explicitly specifying the version number, you ensure that both the CDN and browsers treat the updated script as a completely new file, bypassing the cache and delivering the latest version to your users. This approach is crucial when immediate updates are required, and you cannot afford to wait for caches to expire.
604
+ * Structured data format for compliance reporting
605
+ * Geographic region tracking for multi-jurisdictional compliance
606
+ * Detailed consent method tracking for audit purposes
615
607
 
616
- ### Conclusion
608
+ #### Accessing Consent Records
617
609
 
618
- Understanding how CDN and browser caching work can help you make informed decisions about how to version your scripts and ensure that your users always have access to the latest features and fixes. While using specific versions requires more management, it provides the reliability needed for critical updates. For less critical updates, using @latest might be a convenient option, but be prepared to manually purge the CDN cache and educate your users on clearing their browser's cache if necessary.
610
+ **For Users (ZONE\_3/GDPR)**
619
611
 
620
- <a name="working-with-branches"></a>
612
+ Users in GDPR regions can view their consent ID and timestamp directly in the consent banner after making a choice.
621
613
 
622
- ## 🔀 Working with Branches & Contributing
614
+ **For Administrators**
623
615
 
624
- Developing a project with a structured approach to version control can significantly improve the efficiency and clarity of the development process. Below, we outline two common scenarios: working solo and collaborating with multiple developers.
616
+ Use the Supabase dashboard to query consent records. You can run any of these queries as needed:
625
617
 
626
- ### Single Developer Workflow
618
+ ```sql
619
+ -- Get all consent records for a specific date range
620
+ SELECT * FROM consents
621
+ WHERE action_date >= '2024-01-01'
622
+ AND action_date < '2024-02-01';
623
+ ```
627
624
 
628
- #### Initial Development:
625
+ ```sql
626
+ -- Get consent records by region
627
+ SELECT * FROM consents
628
+ WHERE geo_region = 'ZONE_3';
629
+ ```
629
630
 
630
- All development work can be done directly in the main branch until the first version is ready to be released.
631
+ ```sql
632
+ -- Get specific user's consent history
633
+ SELECT * FROM consents
634
+ WHERE consent_id = 'USER_CONSENT_ID';
635
+ ```
631
636
 
632
- #### Creating a Dev Branch:
637
+ ```sql
638
+ -- Get latest consent for a specific user
639
+ SELECT * FROM get_consent_by_id('USER_CONSENT_ID');
640
+ ```
633
641
 
634
- After the initial release, create a `dev` branch from main for ongoing development using GitHub Desktop:
642
+ ***
635
643
 
636
- - Open GitHub Desktop and navigate to your repository.
637
- - Click on the current branch at the top of the application to view all available branches.
638
- - Choose “New branch”, name it "dev", and click “Create Branch”.
639
- - Push the new branch to the remote repository by clicking on “Publish branch”.
644
+ ### Consent Categories
640
645
 
641
- #### Routine Development:
646
+ CookieFlow™ manages consent across four main categories:
642
647
 
643
- Ensure you are working in the `dev` branch. You can switch branches in GitHub Desktop by clicking on the current branch’s name and selecting the one you wish to switch to.
644
- Your local files will now reflect the state of the `dev` branch. Note that this state is preserved even if you close and reopen GitHub Desktop.
645
- Develop, commit your changes, and push your commits to the `dev` branch.
648
+ #### 1. Marketing Cookies
646
649
 
647
- #### Stashing Changes:
650
+ **Purpose**: Used for advertising and tracking across websites\
651
+ **Includes**: Social media pixels, retargeting pixels, advertising cookies\
652
+ **Control**: Users can enable or disable this category
648
653
 
649
- If you need to switch branches but have uncommitted changes, GitHub Desktop will offer to stash your changes.
650
- Stashing temporarily sets aside your changes, allowing you to switch branches and work on something else. When you’re ready, you can come back and apply your stashed changes.
654
+ #### 2. Analytics Cookies
651
655
 
652
- #### Merging and Releasing:
656
+ **Purpose**: Used to understand how visitors interact with your site\
657
+ **Includes**: Google Analytics, Webflow Analytics, heatmap tools\
658
+ **Control**: Users can enable or disable this category
653
659
 
654
- Once you are ready to release a new version:
660
+ #### 3. Personalization Cookies
655
661
 
656
- - Merge `dev` into `main` via a pull request on GitHub.
657
- - Switch to the `main` branch in GitHub Desktop, pull the latest changes, and run `npm ship` to publish the new version to npm.
662
+ **Purpose**: Used to remember user preferences and personalize experience\
663
+ **Includes**: Language preferences, theme preferences, saved settings\
664
+ **Control**: Users can enable or disable this category
658
665
 
659
- By following these steps, a single developer can maintain a streamlined development workflow while keeping the `main` branch stable. The `dev` branch serves as a space for ongoing development, with the ability to create and apply stashes as needed to manage concurrent tasks.
666
+ #### 4. Essential Cookies (Always On)
660
667
 
661
- ### Multi-Developer Collaboration Workflow
668
+ **Purpose**: Necessary for website functionality\
669
+ **Includes**: Authentication, security, site functionality\
670
+ **Control**: Cannot be disabled—required for site to function
662
671
 
663
- Collaborating with multiple developers requires a more structured approach to manage concurrent development activities and minimize conflicts.
672
+ ***
664
673
 
665
- #### 1. Setting Up Main and Dev Branches:
674
+ ### Adding Project Scripts
666
675
 
667
- Ensure that both `main` and `dev` branches are set up in the repository, and if not, make sure to add a `dev` branch for the whole team to access.
668
- All developers should clone the repository to their local machines using GitHub Desktop:
676
+ Once CookieFlow™ is set up, you need to configure your existing scripts to respect user consent preferences. CookieFlow™ provides two methods for script integration:
669
677
 
670
- - Open GitHub Desktop.
671
- - Go to “File” > “Clone Repository” and select the repository from the list.
672
- - Choose the local path for the repository and click “Clone”.
673
- - Run `pnpm install` to install project dependencies.
678
+ #### Method 1: Adding Scripts Directly in Webflow
674
679
 
675
- #### 2. Creating Feature Branches:
680
+ This method is ideal if you manage scripts directly within your Webflow project using embed elements or custom code.
676
681
 
677
- Each developer works on their specific feature or bug fix by creating a new branch from 'dev', also known as a **feature branch**.
678
- In GitHub Desktop:
682
+ **How It Works**
679
683
 
680
- - Ensure you are on the `dev` branch.
681
- - Click on the current branch at the top, select “New Branch”, name it according to the feature or fix you are working on, and click “Create Branch”.
682
- - Publish the branch to the remote repository by clicking “Publish branch”.
684
+ CookieFlow™ uses HTML attributes to control when scripts load based on user consent. Add the appropriate attributes to all your project scripts:
683
685
 
684
- #### 3. Development, Commit, Push:
686
+ **Important: Remove `<noscript>` Tags for Compliance**
685
687
 
686
- Develop on your feature branch.
687
- Commit your changes in GitHub Desktop:
688
+ **Remove `<noscript>` tags for compliance**: When adding any tracking scripts directly in Webflow, ensure that no `<noscript>` tags are included. If any of your existing scripts contain `<noscript>` tags, remove them as they will bypass consent management and violate compliance requirements.
688
689
 
689
- - Enter a summary and description for your changes.
690
- - Click “Commit to [your-branch-name]”.
691
- - Push your commits to the remote repository by clicking “Push origin”.
690
+ **Example of what NOT to add** (Google Tag Manager `<noscript>` tag):
692
691
 
693
- #### 4. Collaboration and Code Review:
692
+ ```html
693
+ <!-- Google Tag Manager (noscript) -->
694
+ <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX"
695
+ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
696
+ <!-- End Google Tag Manager (noscript) -->
697
+ ```
694
698
 
695
- When a feature is complete:
699
+ This `<noscript>` tag loads tracking scripts even when JavaScript is disabled, completely bypassing consent management and violating privacy regulations.
696
700
 
697
- - Open a pull request on GitHub to merge your branch back into `dev`.
698
- - Team members review the code, suggest changes, and discuss implementations.
699
- - After approval, **merge** the branch into `dev`.
701
+ **Essential Scripts**
700
702
 
701
- #### 5. Syncing Changes:
703
+ **Attribute**: `rd-cookieflow="essential"`\
704
+ **Use for**: Authentication, security, payment processing, accessibility scripts, form validation, load balancing, privacy & consent management
702
705
 
703
- To maintain consistency and minimize merge conflicts, all developers should regularly synchronize their local working branches with the remote repository, ensuring they have the latest changes from the dev branch. Here's how to do it using GitHub Desktop:
706
+ ```html
707
+ <!-- Stripe JS Library -->
708
+ <script rd-cookieflow="essential" src="https://js.stripe.com/v3/"></script>
704
709
 
705
- Fetch Changes from the Remote Repository:
710
+ <!-- Authentication Script -->
711
+ <script rd-cookieflow="essential">
712
+ // Your authentication code here
713
+ </script>
714
+ ```
706
715
 
707
- - Open GitHub Desktop and navigate to your repository.
708
- - Click “Fetch origin” to retrieve the latest changes from the remote repository. If there are new commits on the remote `dev` branch, GitHub Desktop will show an option to “Pull origin”. Click this button to update your local `dev` branch.
716
+ **Analytics Scripts**
709
717
 
710
- Merge Changes from `dev` to Your Feature Branch:
718
+ **Attribute**: `type="disabled" rd-cookieflow="analytics"`\
719
+ **Use for**: Google Analytics, Hotjar, tracking and recording scripts, heatmaps, Microsoft Clarity, Adobe Analytics
711
720
 
712
- - Ensure you are on your feature branch. You can switch branches using the branch dropdown at the top of GitHub Desktop.
713
- - Go to the “Branch” menu at the top and select “Merge into current branch…”.
714
- - A list of branches will appear. Select `dev` from this list and click “Merge dev into [your-feature-branch]”.
715
- - If there are any merge conflicts, resolve them in your preferred code editor.
721
+ ```html
722
+ <!-- Google Analytics 4 -->
723
+ <script type="disabled" rd-cookieflow="analytics" async src="https://www.googletagmanager.com/gtag/js?id=YOURGA4ID"></script>
724
+ <script type="disabled" rd-cookieflow="analytics">
725
+ window.dataLayer = window.dataLayer || [];
726
+ function gtag(){dataLayer.push(arguments);}
727
+ gtag('js', new Date());
728
+ gtag('config', 'YOURGA4ID');
729
+ </script>
716
730
 
717
- Push Your Changes:
731
+ <!-- Hotjar -->
732
+ <script type="disabled" rd-cookieflow="analytics">
733
+ (function(h,o,t,j,a,r){
734
+ h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
735
+ h._hjSettings={hjid:YOUR_HOTJAR_ID,hjsv:6};
736
+ a=o.getElementsByTagName('head')[0];
737
+ r=o.createElement('script');r.async=1;
738
+ r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
739
+ a.appendChild(r);
740
+ })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
741
+ </script>
742
+ ```
718
743
 
719
- - Once the merge is complete and any conflicts are resolved, commit your changes.
720
- - Push your changes to the remote repository to ensure that your feature branch on GitHub is up-to-date.
744
+ **Marketing Scripts**
745
+
746
+ **Attribute**: `type="disabled" rd-cookieflow="marketing"`\
747
+ **Use for**: Tracking pixels, advertising tags, social media integration scripts, retargeting cookies, affiliate tracking, marketing automation
748
+
749
+ ```html
750
+ <!-- Meta Pixel Code -->
751
+ <script type="disabled" rd-cookieflow="marketing">
752
+ !function(f,b,e,v,n,t,s)
753
+ {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
754
+ n.callMethod.apply(n,arguments):n.queue.push(arguments)};
755
+ if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
756
+ n.queue=[];t=b.createElement(e);t.async=!0;
757
+ t.src=v;s=b.getElementsByTagName(e)[0];
758
+ s.parentNode.insertBefore(t,s)}(window, document,'script',
759
+ 'https://connect.facebook.net/en_US/fbevents.js');
760
+ fbq('init', 'YOUR_PIXEL_ID');
761
+ fbq('track', 'PageView');
762
+ </script>
721
763
 
722
- By following these steps, you ensure that your feature branch stays synchronized with the latest changes from `dev`, reducing potential issues when it's time to merge your feature back into the development branch.
764
+ <!-- Google Ads Conversion Tracking -->
765
+ <script type="disabled" rd-cookieflow="marketing">
766
+ gtag('event', 'conversion', {
767
+ 'send_to': 'AW-CONVERSION_ID/CONVERSION_LABEL',
768
+ 'value': 1.0,
769
+ 'currency': 'USD'
770
+ });
771
+ </script>
772
+ ```
723
773
 
724
- #### 6. Adding Collaborators:
774
+ **Personalization Scripts**
725
775
 
726
- Project maintainers can add collaborators:
776
+ **Attribute**: `type="disabled" rd-cookieflow="personalization"`\
777
+ **Use for**: Language preferences, theme or appearance, recommendations, user profile customization, behavioral segmentation, geo-targeting
727
778
 
728
- - Go to the repository on GitHub.
729
- - Click “Settings” > “Manage access” > “Invite a collaborator”.
779
+ ```html
780
+ <!-- Language Preference Script -->
781
+ <script type="disabled" rd-cookieflow="personalization">
782
+ function setLanguagePreference(lang) {
783
+ localStorage.setItem('preferred-language', lang);
784
+ document.documentElement.lang = lang;
785
+ }
786
+ </script>
730
787
 
731
- #### 7. Preparing for Release:
788
+ <!-- Theme Customization Script -->
789
+ <script type="disabled" rd-cookieflow="personalization">
790
+ function applyUserTheme(theme) {
791
+ document.body.className = theme;
792
+ localStorage.setItem('user-theme', theme);
793
+ }
794
+ </script>
795
+ ```
732
796
 
733
- Once `dev` is stable and ready for release:
797
+ **Important Notes for Webflow Integration**
734
798
 
735
- - Create a pull request to merge `dev` into main.
736
- - Conduct a final review and merge the changes.
799
+ 1. **Add attributes to embed elements**: In Webflow, when adding scripts via embed elements, include the attributes in the opening `<script>` tag
800
+ 2. **Scripts load automatically**: Once users give consent, CookieFlow™ automatically enables the appropriate scripts
801
+ 3. **Essential scripts always load**: Scripts with `rd-cookieflow="essential"` load immediately without requiring consent
737
802
 
738
- #### 8. Shipping to npm:
803
+ ***
739
804
 
740
- Switch to the `main` branch in GitHub Desktop:
805
+ #### Method 2: Adding Scripts via Google Tag Manager
741
806
 
742
- - Fetch the latest changes by clicking “Fetch origin”.
743
- - Pull the changes by clicking “Pull origin” (if there are new commits to pull).
744
- - Run `npm ship` to publish the new version to npm.
807
+ This method is recommended if you use Google Tag Manager to manage your website scripts and tracking.
745
808
 
746
- ### Conclusion
809
+ **Prerequisites**
747
810
 
748
- These workflows are designed to cater to different scales of development, ensuring code integrity and facilitating collaboration. The single developer workflow is straightforward and suited for smaller projects or the initial development phases. The multi-developer collaboration workflow, on the other hand, is robust and accommodates concurrent development activities, making it suitable for larger teams and more complex projects. This structure ensures that every developer's changes are isolated in their own feature branches, allowing for independent development, easy code review, and reduced merge conflicts.
811
+ **Remove `<noscript>` tags for compliance**: When installing Google Tag Manager, do not add the `<noscript>` tag after the opening `<body>` tag. If you already have Google Tag Manager installed, remove that part from Webflow.
749
812
 
750
- <a name="condensed-guide-for-existing-devkit-users"></a>
813
+ **Step 1: Set Up Triggers in Google Tag Manager**
751
814
 
752
- # 🤏 Condensed Guide for Existing DevKit Users 😎
815
+ Go to **Workspace Triggers** and click **New** to create triggers for each consent category:
753
816
 
754
- Once you've become a seasoned DevKit pro, you can skip the detailed Readme aimed at new users, and jump straight into this condensed guide instead:
817
+ **Essential Cookie Trigger**
755
818
 
756
- ## Table of Contents (Condensed Guide)
819
+ * **Name**: `Essential Cookie Activated`
820
+ * **Type**: Other → Custom Event
821
+ * **Event Name**: `essential-activated`
822
+ * **Fires On**: Some Custom Events
823
+ * **Condition**: Event equals `essential-activated`
757
824
 
758
- - [Installation](#installation2)
759
- - [Step 1: Setup Template](#step-1-setup-template2)
760
- - [Step 2: Setup Public SSH Key](#step-2-setup-public-ssh-key-first-time-only2)
761
- - [Step 3: Setup Private SSH Key](#step-3-setup-private-ssh-key-for-every-new-project2)
762
- - [Step 4: Setup NPM](#step-4-setup-npm2)
763
- - [Step 5: Setup Your Project](#step-5-setup-your-project2)
764
- - [How to use DevKit](#how-to-use-devkit2)
765
- - [Building & Testing](#building-testing2)
766
- - [Importing Scripts](#importing-scripts-in-webflow2)
767
- - [Shipping to NPM](#shipping-to-npm2)
768
- - [Addressing Version Caching](#addressing-version-caching2)
769
- - [Working with Branches & Contributing](#working-with-branches2)
825
+ **Analytics Cookie Trigger**
770
826
 
771
- <a name="installation2"></a>
827
+ * **Name**: `Analytics Cookie Activated`
828
+ * **Type**: Other → Custom Event
829
+ * **Event Name**: `analytics-activated`
830
+ * **Fires On**: Some Custom Events
831
+ * **Condition**: Event equals `analytics-activated`
772
832
 
773
- ## 🏁 Installation
833
+ **Marketing Cookie Trigger**
774
834
 
775
- <a name="step-1-setup-template2"></a>
835
+ * **Name**: `Marketing Cookie Activated`
836
+ * **Type**: Other → Custom Event
837
+ * **Event Name**: `marketing-activated`
838
+ * **Fires On**: Some Custom Events
839
+ * **Condition**: Event equals `marketing-activated`
776
840
 
777
- ### Step 1: Setup Template
841
+ **Personalization Cookie Trigger**
778
842
 
779
- - Click on "Use this template" in GitHub and clone as private repository.
780
- - Open locally with GitHub Desktop and open project in Visual Studio Code.
843
+ * **Name**: `Personalization Cookie Activated`
844
+ * **Type**: Other Custom Event
845
+ * **Event Name**: `personalization-activated`
846
+ * **Fires On**: Some Custom Events
847
+ * **Condition**: Event equals `personalization-activated`
781
848
 
782
- <a name="step-2-setup-public-ssh-key-first-time-only2"></a>
849
+ **Step 2: Configure Your Tags**
783
850
 
784
- ### Step 2: Setup SSH Key Pair & Public Key (First-Time Only)
851
+ For each existing or new tag in Google Tag Manager:
785
852
 
786
- #### Check for Existing SSH Keys:
853
+ **Essential Scripts**
787
854
 
788
- ```
789
- ls -al ~/.ssh
790
- ```
855
+ * **Trigger**: Essential Cookie Activated
856
+ * **Use for**: Authentication, security, payment processing, accessibility scripts, form validation, load balancing, privacy & consent management
791
857
 
792
- Look for files named `id_rsa.pub`, `id_ecdsa.pub`, or `id_ed25519.pub`. If such a file exists, you can skip the next steps and jump to "**Add public key to GitHub**" if you haven't already done so previously.
858
+ **Analytics Scripts**
793
859
 
794
- #### Generate SSH Key Pair:
860
+ * **Trigger**: Analytics Cookie Activated
861
+ * **Use for**: Google Analytics, Hotjar, tracking and recording scripts, heatmaps, Microsoft Clarity, Adobe Analytics
795
862
 
796
- ```
797
- Run ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
798
- ```
863
+ **Marketing Scripts**
799
864
 
800
- #### Add Key to SSH-Agent:
865
+ * **Trigger**: Marketing Cookie Activated
866
+ * **Use for**: Tracking pixels, advertising tags, social media integration scripts, retargeting cookies, affiliate tracking, marketing automation
801
867
 
802
- ```
803
- eval "$(ssh-agent -s)"
804
- ssh-add ~/.ssh/id_rsa
805
- ```
868
+ **Personalization Scripts**
806
869
 
807
- #### Copy public key:
870
+ * **Trigger**: Personalization Cookie Activated
871
+ * **Use for**: Language preferences, theme or appearance, recommendations, user profile customization, behavioral segmentation, geo-targeting
808
872
 
809
- ```
810
- cat ~/.ssh/id_rsa.pub | pbcopy
811
- ```
873
+ **Step 3: Add Advanced Consent Settings**
812
874
 
813
- Or manual copy:
875
+ For each tag, go to **Tag Configuration → Advanced Settings → Consent Settings** and select **Require additional consent for tag to fire**:
814
876
 
815
- ```
816
- cat ~/.ssh/id_rsa.pub
817
- ```
877
+ **Essential Scripts**
818
878
 
819
- #### Add public key to GitHub:
879
+ * **Required Consent**: `security_storage`
820
880
 
821
- Go to GitHub > Settings > SSH and GPG keys > New SSH key, paste key, and save.
881
+ **Analytics Scripts**
822
882
 
823
- <a name="step-3-setup-private-ssh-key-for-every-new-project2"></a>
883
+ * **Required Consent**: `analytics_storage`
824
884
 
825
- ### Step 3: Setup Private SSH Key (Per Project)
885
+ **Marketing Scripts**
826
886
 
827
- #### Copy private key:
887
+ * **Required Consent**: `ad_storage`
828
888
 
829
- ```
830
- cat ~/.ssh/id_rsa | pbcopy
831
- ```
889
+ **Personalization Scripts**
832
890
 
833
- Or manual copy:
891
+ * **Required Consent**: `personalization_storage` and `functionality_storage`
834
892
 
835
- ```
836
- cat ~/.ssh/id_rsa
837
- ```
893
+ **Step 4: Publish & Test**
838
894
 
839
- Go to Repo > Settings > Secrets and variables > Actions > New repository secret.
840
- Name it `SSH_TOKEN` and paste key content.
895
+ 1. **Publish**: Click **Submit**, name your version, and hit **Publish**
896
+ 2. **Test**: Click **Preview**, enter your website URL to initiate test mode
897
+ 3. **Verify**: By default, you should only see essential tags firing without further consent
898
+ 4. **Test Consent**: Toggle different cookie types on your previewed website to verify their respective tags fire correctly
841
899
 
842
- <a name="step-4-setup-npm2"></a>
900
+ **Troubleshooting GTM Integration**
843
901
 
844
- ### Step 4: Setup NPM
902
+ * **Tags not firing**: Check that triggers are properly configured and attached to tags
903
+ * **Consent not working**: Verify that advanced consent settings are properly configured
904
+ * **Essential scripts not loading**: Ensure essential tags have the correct trigger and consent settings
845
905
 
846
- - (Optional) Create NPM Organization: Skip if not needed.
847
- - Create NPM Access Token: Generate a classic token, automation type, named descriptively.
848
- - Copy NPM Token: Ensure you've copied it; it’s not retrievable later.
849
- - Add Token to GitHub as Secret: In your project’s GitHub settings, under Secrets and variables, add a new secret named `NPM_TOKEN` and paste the token.
906
+ ***
850
907
 
851
- <a name="step-5-setup-your-project2"></a>
908
+ ## Manual Setup
852
909
 
853
- ### Step 5: Setup Your Project Setup
910
+ ### Setup Guide
854
911
 
855
- #### Install pnpm: (Skip if already installed)
912
+ If you prefer to build your own UI or need to customize the implementation beyond the prebuilt component, you can manually set up CookieFlow™ by adding the required HTML elements and attributes to your Webflow project.
856
913
 
857
- ```
858
- npm install -g pnpm
859
- ```
914
+ #### Quick Start
860
915
 
861
- #### Install dependencies:
916
+ 1. Add the CookieFlow™ script to your Webflow project
917
+ 2. Create the required HTML elements in your Webflow project
918
+ 3. Add the necessary attributes to each element
919
+ 4. Customize the styling to match your brand
862
920
 
863
- ```
864
- pnpm install
865
- ```
921
+ ***
866
922
 
867
- <a name="how-to-use-devkit2"></a>
923
+ ### Adding the Script
868
924
 
869
- # 🚀 How to Use DevKit
925
+ Add the following script to your Webflow project's **global settings**, inside the `<head>` tag:
870
926
 
871
- <a name="building-testing2"></a>
872
-
873
- ## 🧑‍💻 Building & Testing
874
-
875
- ### Run a Local Development Server:
876
-
877
- ```
878
- pnpm dev
927
+ ```html
928
+ <script
929
+ src="https://cdn.jsdelivr.net/npm/@reform-digital/cookie-flow@1.3.8/prod/index.js"
930
+ rd-consent-storage-url="YOUR_SUPABASE_URL"
931
+ rd-consent-storage-api="YOUR_SUPABASE_API_KEY"
932
+ ></script>
879
933
  ```
880
934
 
881
- ### Run a Local Production Server:
935
+ #### What's Next?
882
936
 
883
- ```
884
- pnpm prod
885
- ```
886
-
887
- <a name="importing-scripts-in-webflow2"></a>
937
+ * **Configure your Supabase database**: Follow the [Supabase Setup](#-supabase-setup) guide in Option 1
938
+ * **Learn about script attributes**: See the [Script Configuration](#-script-configuration) section for all available attributes and customization options
939
+ * **Understand regional compliance**: Check the [Regional Compliance Overview](#regional-compliance-overview) section to learn how CookieFlow™ adapts to different regions
888
940
 
889
- ## ⤵️ Importing Scripts
941
+ ***
890
942
 
891
- ### 1️⃣ Traditional Method:
943
+ ### Elements & Attributes
892
944
 
893
- - Operation: Run your local server using pnpm dev or pnpm prod.
894
- - Script Logging: DevKit logs script tags for JavaScript and CSS files from the src folder.
895
- - Integration: Manually copy and paste script tags to your Webflow pages or global settings, being mindful to switch between development and production tags as needed.
945
+ CookieFlow™ uses **HTML data attributes** to identify and control UI elements. These attributes start with `rd-cookieflow` (Reform Digital CookieFlow).
896
946
 
897
- ### 2️⃣ Automated Method (Recommended):
947
+ #### Core Components
898
948
 
899
- ### Core DevKit Scripts (Global):
949
+ **1. Wrapper Element**
900
950
 
901
- #### `Main Settings`: Add in global `<head>` tag
951
+ **Purpose**: Contains all CookieFlow™ components\
952
+ **Attribute**: `rd-cookieflow="wrapper"`
902
953
 
903
- ```
904
- <!-- RD® Webflow DevKit / Main Settings -->
905
- <script>
906
- window.npmPath = "@reform-digital/sample-project@1.0.0"; // Update this once you have shipped to npm.
907
- window.devMode = true; // Change to false in production
908
- window.classViewer = true; // Helper to display classes and ids in DevMode
909
- window.localPort = 3000; // Also change in bin/localport.js in VS Code
910
- </script>
954
+ ```html
955
+ <div rd-cookieflow="wrapper">
956
+ <!-- All other components go inside here -->
957
+ </div>
911
958
  ```
912
959
 
913
- #### `Style-Loader`: Add in global `<head>` tag
960
+ **2. Manager Component**
914
961
 
915
- ```
916
- <!-- RD® Webflow DevKit / Style Loader -->
917
- <script src="https://cdn.jsdelivr.net/npm/@reform-digital/webflow-devkit-utils@1.1.0/prod/style-loader.js"></script>
918
- ```
962
+ **Purpose**: Small button/floating element that allows users to reopen the consent interface\
963
+ **Attribute**: `rd-cookieflow="manager"`\
964
+ **Additional**: Add `rd-cookieflow="manager-interaction"` to control show/hide state
919
965
 
920
- #### `Script-Loader`: Add before global `</body>` closing tag
966
+ **Position**: Typically positioned as a floating button, often in the bottom-right corner
921
967
 
922
- ```
923
- <!-- RD® Webflow DevKit / Script Loader -->
924
- <script src="https://cdn.jsdelivr.net/npm/@reform-digital/webflow-devkit-utils@1.1.0/prod/script-loader.js"></script>
925
- ```
968
+ **3. Banner Components**
926
969
 
927
- ### Project Code (Page level):
970
+ **Purpose**: Display consent options to users when they first visit
928
971
 
929
- #### Page `Scripts`: Add before page `</body>` closing tag
972
+ There are **three banner types**, one for each compliance zone:
930
973
 
931
- ```
932
- <!-- RD® Webflow DevKit / Page Scripts -->
933
- <script>
934
- const pageScripts = ["home.js"];
935
- loadWebflowScripts(pageScripts, npmPath);
936
- </script>
937
- ```
974
+ * **Banner Zone 1** (Basic Notice): `rd-cookieflow="banner-zone-one"`
975
+ * **Banner Zone 2** (Opt-Out/CCPA): `rd-cookieflow="banner-zone-two"`
976
+ * **Banner Zone 3** (Opt-In/GDPR): `rd-cookieflow="banner-zone-three"`
938
977
 
939
- #### Page `Styles`: Add in page `<head>` tag
978
+ **Important**: All three banners are hidden by default. CookieFlow™ will automatically remove the banners that don't apply to the user's location.
940
979
 
941
- ```
942
- <!-- RD® Webflow DevKit / Page Styles -->
943
- <script>
944
- const pageStyles = ["home.css"];
945
- loadWebflowStylesheets(pageStyles, npmPath);
946
- </script>
947
- ```
980
+ **Additional**: Add `rd-cookieflow="banner-interaction"` to control show/hide state
948
981
 
949
- ### Project Code (Global):
982
+ **4. Settings/Preferences Component**
950
983
 
951
- #### Global `Scripts`: Add before global `</body>` closing tag, under Script Loader.
952
-
953
- ```
954
- <!-- RD® Webflow DevKit / Global Scripts -->
955
- <script>
956
- const globalScripts = ["global.js", "analytics.js"];
957
- loadWebflowScripts(globalScripts, npmPath);
958
- </script>
959
- ```
984
+ **Purpose**: Detailed consent management modal where users can customize their preferences\
985
+ **Attribute**: `rd-cookieflow="settings"`\
986
+ **Additional**: Add `rd-cookieflow="preferences-interaction"` to control show/hide state
960
987
 
961
- #### Global `Styles`: Add in global `<head>` tag, under Style Loader.
988
+ **Components Inside Settings**:
962
989
 
963
- ```
964
- <!-- RD® Webflow DevKit / Global Styles -->
965
- <script>
966
- const globalStyles = ["global.css", "animation.css"];
967
- loadWebflowStylesheets(globalStyles, npmPath);
968
- </script>
969
- ```
990
+ * Header text
991
+ * Consent category toggles
992
+ * Action buttons (Accept All, Reject All, Accept Selected)
993
+ * Close button
970
994
 
971
- <a name="shipping-to-npm2"></a>
995
+ **5. Consent Info Banner (GDPR Only)**
972
996
 
973
- ## 🚀 Shipping to NPM
997
+ **Purpose**: Displays consent ID and information about cookies for GDPR users\
998
+ **Attribute**: `rd-cookieflow="consent-banner"`\
999
+ **Additional**: Add `rd-cookieflow="consent-interaction"` to control show/hide state
974
1000
 
975
- ```
976
- pnpm ship
977
- ```
1001
+ #### Essential UI Elements Within Components
978
1002
 
979
- If you are using the GitHub extension for VS Code, grant the necessary permissions if prompted.
1003
+ **Consent Buttons**
980
1004
 
981
- ### Post-Shipment Steps:
1005
+ All consent-related buttons need these attributes:
982
1006
 
983
- #### Automated:
1007
+ * **Accept All**: `rd-cookieflow="accept"`
1008
+ * **Reject All**: `rd-cookieflow="reject"`
1009
+ * **Custom/Selected**: `rd-cookieflow="accept-selected"`
1010
+ * **Open Settings**: `rd-cookieflow="open-settings"`
1011
+ * **Close**: `rd-cookieflow="close"`
984
1012
 
985
- Update `npmPath` with your own path in the global `<head>`.
1013
+ **Consent Checkboxes**
986
1014
 
987
- #### Traditional:
1015
+ For the settings/preferences modal, add checkboxes for each consent category:
988
1016
 
989
- Replace local script tags located in global and page-specific `</body>` to:
1017
+ * **Marketing Cookies**:
1018
+ * Checkbox: `rd-cookieflow="marketing-checkbox"`
1019
+ * Toggle interaction: `rd-cookieflow="toggle-interaction"` (inside the checkbox container)
1020
+ * State display: `rd-cookieflow="marketing-state"` (to show On/Off text)
1021
+ * **Analytics Cookies**:
1022
+ * Checkbox: `rd-cookieflow="analytics-checkbox"`
1023
+ * Toggle interaction: `rd-cookieflow="toggle-interaction"` (inside the checkbox container)
1024
+ * State display: `rd-cookieflow="analytics-state"` (to show On/Off text)
1025
+ * **Personalization Cookies**:
1026
+ * Checkbox: `rd-cookieflow="personalization-checkbox"`
1027
+ * Toggle interaction: `rd-cookieflow="toggle-interaction"` (inside the checkbox container)
1028
+ * State display: `rd-cookieflow="personalization-state"` (to show On/Off text)
990
1029
 
991
- ```
992
- <script src="https://cdn.jsdelivr.net/npm/@your-npm-username/your-package-name@version/your-filename.js"></script>
993
- ```
1030
+ **Scroll Lock Attribute**
994
1031
 
995
- Replace local style tags in global and page-specific `<head>` to:
1032
+ To prevent page scrolling when the settings modal is open, add this attribute to the settings component container:
996
1033
 
1034
+ ```html
1035
+ <div rd-cookieflow-scroll="disabled">
1036
+ <!-- Settings modal content -->
1037
+ </div>
997
1038
  ```
998
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@your-npm-username/your-package-name@version/your-filename.css">
999
- ```
1000
-
1001
- <a name="addressing-version-caching2"></a>
1002
-
1003
- ## 🔄 Addressing Version Caching
1004
-
1005
- ### @latest Versioning
1006
-
1007
- - Initial Release: @latest (or omitting @version) is ok for initial release.
1008
- - Subsequent Releases: @latest might lead to outdated content due to CDN and browser caching.
1009
-
1010
- ### Cache Management
1011
-
1012
- - CDN Cache: Manually purge via [jsDelivr’s Purge Tool](https://www.jsdelivr.com/tools/purge).
1013
- - Browser Cache: Educate users; no direct control, can only hard refresh or clear own browser cache.
1014
-
1015
- ### Use Specific Versions to Prevent Caching Issues
1016
-
1017
- - Automated Import: npm path `"@your-npm-username/your-package-name@version"`
1018
- - Traditional Import: src path `"https://cdn.jsdelivr.net/npm/@your-npm-username/your-package-name@version/your-filename.js"`
1019
-
1020
- <a name="working-with-branches2"></a>
1021
-
1022
- ## 🔀 Working with Branches & Contributing
1023
-
1024
- ### Single Developer Workflow
1025
1039
 
1026
- - **Initial Development:** Work directly in main branch.
1027
- - **Creating a Dev Branch:** After initial release, create a dev branch.
1028
- - **Routine Development:** Work in dev, commit changes, push commits.
1029
- - **Merging and Releasing:** Merge dev into main, publish to npm.
1040
+ #### Example Structure
1030
1041
 
1031
- ### Multi-Developer Collaboration Workflow
1042
+ Here's an example of a complete CookieFlow™ structure:
1032
1043
 
1033
- - **Setting Up Main and Dev Branches:** Ensure main and dev branches are set up.
1034
- - **Creating Feature Branches:** Developers create feature branches from dev.
1035
- - **Development, Commit, Push:** Work on feature, commit, and push.
1036
- - **Collaboration and Code Review:** Open pull requests, review code, merge into dev.
1037
- - **Syncing Changes:** Regularly fetch and merge changes from dev to avoid conflicts.
1038
- - **Adding Collaborators:** Project maintainers can add collaborators through GitHub settings.
1039
- - **Preparing for Release:** Merge dev into main, prepare for npm release.
1040
- - **Shipping to npm:** Switch to main, fetch latest, pull changes, publish to npm.
1044
+ ```html
1045
+ <div rd-cookieflow="wrapper" style="display: none;">
1046
+
1047
+ <!-- Manager Button (always visible) -->
1048
+ <div rd-cookieflow="manager">
1049
+ <button rd-cookieflow="open-settings">Cookie Settings</button>
1050
+ </div>
1041
1051
 
1042
- ### Conclusion
1052
+ <!-- Zone 1 Banner (Basic Notice) -->
1053
+ <div rd-cookieflow="banner-zone-one">
1054
+ <p>We use cookies to enhance your experience...</p>
1055
+ <button rd-cookieflow="accept">Accept</button>
1056
+ </div>
1043
1057
 
1044
- - Single developer workflow for smaller projects or initial phases.
1045
- - Multi-developer collaboration workflow for larger teams and complex projects.
1058
+ <!-- Zone 2 Banner (Opt-Out/CCPA) -->
1059
+ <div rd-cookieflow="banner-zone-two">
1060
+ <p>We use cookies to enhance your experience...</p>
1061
+ <button rd-cookieflow="accept">Accept All</button>
1062
+ <button rd-cookieflow="reject">Reject All</button>
1063
+ <button rd-cookieflow="open-settings">Manage Preferences</button>
1064
+ </div>
1046
1065
 
1047
- # Made with 💜 by Reform Digital®
1066
+ <!-- Zone 3 Banner (Opt-In/GDPR) -->
1067
+ <div rd-cookieflow="banner-zone-three">
1068
+ <p>We use cookies to enhance your experience. Choose your preferences...</p>
1069
+ <button rd-cookieflow="accept">Accept All</button>
1070
+ <button rd-cookieflow="reject">Reject All</button>
1071
+ <button rd-cookieflow="accept-selected">Accept Selected</button>
1072
+ <button rd-cookieflow="open-settings">Customize</button>
1073
+ </div>
1074
+
1075
+ <!-- Settings/Preferences Modal -->
1076
+ <div rd-cookieflow="settings" rd-cookieflow-scroll="disabled">
1077
+ <h2>Cookie Preferences</h2>
1078
+
1079
+ <!-- Marketing Toggle -->
1080
+ <div>
1081
+ <input type="checkbox" rd-cookieflow="marketing-checkbox">
1082
+ <button rd-cookieflow="toggle-interaction"></button>
1083
+ <span rd-cookieflow="marketing-state">Off</span>
1084
+ </div>
1085
+
1086
+ <!-- Analytics Toggle -->
1087
+ <div>
1088
+ <input type="checkbox" rd-cookieflow="analytics-checkbox">
1089
+ <button rd-cookieflow="toggle-interaction"></button>
1090
+ <span rd-cookieflow="analytics-state">Off</span>
1091
+ </div>
1092
+
1093
+ <!-- Personalization Toggle -->
1094
+ <div>
1095
+ <input type="checkbox" rd-cookieflow="personalization-checkbox">
1096
+ <button rd-cookieflow="toggle-interaction"></button>
1097
+ <span rd-cookieflow="personalization-state">Off</span>
1098
+ </div>
1099
+
1100
+ <button rd-cookieflow="accept">Accept All</button>
1101
+ <button rd-cookieflow="reject">Reject All</button>
1102
+ <button rd-cookieflow="accept-selected">Accept Selected</button>
1103
+ <button rd-cookieflow="close">Close</button>
1104
+ </div>
1105
+
1106
+ <!-- GDPR Consent Info Banner -->
1107
+ <div rd-cookieflow="consent-banner">
1108
+ <p>Your Consent ID: [will be populated automatically]</p>
1109
+ <button rd-cookieflow="open-settings">Manage Cookies</button>
1110
+ <button rd-cookieflow="close">Close</button>
1111
+ </div>
1112
+
1113
+ </div>
1114
+ ```
1115
+
1116
+ ***