https://github.com/futurenorthants/cookiebanner
A self-contained cookie banner for Google Analytics
https://github.com/futurenorthants/cookiebanner
cookie-banner cookie-banner-javascript cookies google-analytics google-analytics-4
Last synced: 4 months ago
JSON representation
A self-contained cookie banner for Google Analytics
- Host: GitHub
- URL: https://github.com/futurenorthants/cookiebanner
- Owner: FutureNorthants
- License: gpl-3.0
- Created: 2023-12-18T15:09:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-19T11:12:41.000Z (over 2 years ago)
- Last Synced: 2025-09-09T17:02:04.371Z (9 months ago)
- Topics: cookie-banner, cookie-banner-javascript, cookies, google-analytics, google-analytics-4
- Language: HTML
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cookie Banner
A cookie banner that uses Google Analytics consent mode to determine whether to store cookies on the user's machine.
It follows the methodology on this tutorial: https://support.google.com/analytics/answer/9976101?hl=en
## Usage
1. Copy the contents of `src/cookie-banner.html` into your page.
1. Find and replace `LINK_TO_COOKIE_POLICY` with a link to your cookie policy url.
1. Find and replace `GOOGLE_ANALYTICS_ID` with your Google Analytics V4 id.
1. When the user clicks Accept, it will store settings in the browsers local storage allowing functionality, security and analytics.
1. When the user clicks Reject, it will store settings in the browsers local storage to deny all.