{"id":51142169,"url":"https://github.com/gencat/ICGC-Cookie-GDPR","last_synced_at":"2026-07-14T07:01:30.783Z","repository":{"id":40954608,"uuid":"134835712","full_name":"gencat/ICGC-Cookie-GDPR","owner":"gencat","description":"A small cookie consent banner that complies with the EU GDPR","archived":false,"fork":false,"pushed_at":"2023-10-26T22:18:52.000Z","size":619,"stargazers_count":5,"open_issues_count":4,"forks_count":1,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-02T11:12:35.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gencat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-05-25T09:36:00.000Z","updated_at":"2022-12-21T08:13:40.000Z","dependencies_parsed_at":"2023-02-15T11:46:57.943Z","dependency_job_id":"3bb46b4e-eaf2-4abe-8e5b-045cc2f37fed","html_url":"https://github.com/gencat/ICGC-Cookie-GDPR","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gencat/ICGC-Cookie-GDPR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gencat%2FICGC-Cookie-GDPR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gencat%2FICGC-Cookie-GDPR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gencat%2FICGC-Cookie-GDPR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gencat%2FICGC-Cookie-GDPR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gencat","download_url":"https://codeload.github.com/gencat/ICGC-Cookie-GDPR/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gencat%2FICGC-Cookie-GDPR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35450066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-14T02:00:06.603Z","response_time":114,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-26T00:00:40.441Z","updated_at":"2026-07-14T07:01:30.778Z","avatar_url":"https://github.com/gencat.png","language":"JavaScript","funding_links":[],"categories":["Cartografía y Territorio"],"sub_categories":[],"readme":"# ICGC-Cookie-GDPR\n\nA small cookie consent banner that complies with the EU GDPR.\n\nThis library presents the user with a small banner that shows two buttons to comply with the EU GDPR law. \n\n---\nIf the user _allows_ the use of cookies, **a cookie is set to remember the selected option and enables the tracking by Google Analytics**. If the user _denies_ the use of cookies and the _removeGACookies_ configuration option is set to **true**, **the option is stored and Google Analytics trackers are disabled**. If the user _denies_ the use of cookies and the _removeGACookies_ configuration option is set to **false(default option)**, **the option is stored, and Google Analytics trackers are enabled so they must be configured to perform IP anonymization**. A _configure cookies_ button is shown whenever any option is chosen so the user can change his mind\n---\n\n**Notice:** By default, this library doesn't stop Google Analytics tracking so Google Analytics Cookies must be configured to anomymize the IP to comply with the GDPR. If you want the Google Analytics cookies to be disabled, the _removeGACookies_ configuration option must be set to **true**\n\nYou can see it working in [instamaps.cat](https://www.instamaps.cat/) and all the other prototypes in [betaportal](http://betaportal.icgc.cat/)\n\n## Using the banner on your website\n### Get the required files\n* Copy the files found in the _dist_ folder to your project and use it in your html\n\n\n```html\n\u003clink rel=\"stylesheet\" href=\"./dist/cookies-icgc.min.css\"\u003e\n\u003cscript src=\"./dist/cookies-icgc.js\"\u003e\u003c/script\u003e\n```\n\n* or use the github stored files to always use the last version\n```html\n\u003clink rel=\"stylesheet\" href=\"https://gencat.github.io/ICGC-Cookie-GDPR/dist/cookies-icgc.min.css\"\u003e\n\u003cscript src=\"https://gencat.github.io/ICGC-Cookie-GDPR/dist/cookies-icgc.js\"\u003e\u003c/script\u003e\n```\n\n**Note: If you need to support Internet Explorer 11 use the *cookies-icgc-ie11.js***\n\n### Create the cookie manager object in a script\n**Note:** It **must** be executed before any code that sets cookies, including Google Analytics\n\n```html\n\u003cscript\u003e\n\t\tconst cuqui = new icgc.CookiesICGC(\"yourdomain.com\", \t[\"your-google-analytics-id\", \"another-google-analytics-id\"], {configBtnSelector: \"#config-button-selector\"});\n\t\tcuqui.setCookiesEnabledHandler(() =\u003e { console.log(\"Cookies enabled\")});\n\t\tcuqui.setCookiesDisabledHandler(() =\u003e { console.log(\"Cookies disabled\")});\n\u003c/script\u003e\n```\nWhere:\n\n* The first parameter should be the domain where the cookies are stored\n* The second one is a list of Google Analytics Tracking IDs that will be enabled/disabled if the user allows/disallows it. **Note:** This library just manages already present Google Analytics trackers, it does **NOT** add or remove trackers.\n* The third one is an options parameter that's used to configure the popup. You can find the list of possible parameters [here](https://raw.githubusercontent.com/gencat/ICGC-Cookie-GDPR/master/src/defaultOptions.js) but the most important ones are the following ones:\n\n|Element|Subelement|Description|\n|---|---|---|\n|cookie|name|This is the name of the cookie that will be set to save the user preferences|\n|content|message|The text used by the popup|\n||allow|The text used in the Allow button|\n||deny|The text used in the Deny button|\n||config|The text used in the configuration button that will be shown when the user has choosen some option|\n||href|The URL where the user will be directed when the privacy policy link is pressed|\n|configBtnSelector||A div element selector **already existing on your HTML** where the configure cookies button will be shown. If this parameter is not set, a div with class _config-popup_ will be created. If it's set to a non existing div, one is created in the body|\n* The _setCookiesEnabledHandler_ function is used to set a callback that will be run when the user has enabled the cookies by pressing the **Allow** button\n* The _setCookiesDisabledHandler_ function is used to set a callback that will be run when the user has disabled the cookies by pressing the **Deny** button\n\n#### Examples\nThese examples work on the following HTML\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n\t\u003cmeta charset=\"UTF-8\"\u003e\n\t\u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n\t\u003cmeta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"\u003e\n\t\u003ctitle\u003eDocument\u003c/title\u003e\n\t\u003clink rel=\"stylesheet\" href=\"./dist/cookies-icgc.min.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\t\u003cdiv id=\"control\"\u003e\u003c/div\u003e\n\t\u003cscript src=\"./dist/cookies-icgc.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n```html\n\u003cscript\u003e\n\tnew icgc.CookiesICGC(\"instamaps.cat\", [], {configBtnSelector: \"#control\"});\n\u003c/script\u003e\n```\n![Simple example](./docs/examples/no-customization.png)\nShows the default popup, sets a cookie on the _instamaps.cat_ domain and doesn't manage any Google Analytics tracker.\n\n\n```html\n\u003cscript\u003e\n\tnew icgc.CookiesICGC(\"instamaps.cat\", [\"UA-12345678-1\"], {configBtnSelector: \"#control\"});\n\u003c/script\u003e\n```\n![Simple example](./docs/examples/no-customization.png)\nShows the default popup, sets a cookie on the _instamaps.cat_ domain, manages a Google Analytics tracker and shows the configure button in the div with id _control_.\n\n```html\n\u003cscript\u003e\n\tnew icgc.CookiesICGC(\"instamaps.cat\", [\"UA-12345678-1\"], {\n\t\tconfigBtnSelector: \"#control\", \n\t\tcontent: { \n\t\t\tallow: \"Allow\", \n\t\t\tdeny: \"Deny\"\n\t\t}\n\t});\n\u003c/script\u003e\n```\n![Simple customization example](./docs/examples/customization.png)\nShows the default popup, sets a cookie on the _instamaps.cat_ domain, manages a Google Analytics tracker, shows the configure button in the div with id _control_ and changes the button labels to *Allow* and *Deny*\n\n```html\n\u003cscript\u003e\n\tnew icgc.CookiesICGC(\"instamaps.cat\", [\"UA-12345678-1\"], {\n\t\tconfigBtnSelector: \"#control\", \n\t\tpalette:{\n\t\t\tpopup: {background: \"#00b050\"}, \n\t\t\tbutton: {background: \"#222222\"},\n\t\t}\n\t});\n\u003c/script\u003e\n```\n![Simple customization example](./docs/examples/color-customization.png)\nShows the default popup, sets a cookie on the _instamaps.cat_ domain, manages a Google Analytics tracker, shows the configure button in the div with id _control_ and changes the button colors\n\n```html\n\u003cscript\u003e\n\tconst cuqui = new icgc.CookiesICGC(\"127.0.0.1\", [\"UA-12345678-1\"], {\n\t\tconfigBtnSelector: \"#control\"\n\t} );\n\tcuqui.setCookiesEnabledHandler(() =\u003e { console.log(\"Cookies enabled\")});\n\tcuqui.setCookiesDisabledHandler(() =\u003e { console.log(\"Cookies disabled\")});\n\u003c/script\u003e\n```\n![Simple customization example](./docs/examples/color-customization.png)\nShows the default popup, sets a cookie on the _instamaps.cat_ domain, manages a Google Analytics tracker, shows the configure button in the div with id _control_ and changes the button colors\n\n```html\n\u003cscript\u003e\n\tconst cuqui = new icgc.CookiesICGC(\"127.0.0.1\", [\"UA-12345678-1\"]);\n\tcuqui.setCookiesEnabledHandler(() =\u003e { console.log(\"Cookies enabled\")});\n\tcuqui.setCookiesDisabledHandler(() =\u003e { console.log(\"Cookies disabled\")});\n\u003c/script\u003e\n```\n![Default popup example](./docs/examples/popup.png)\n\nShows the default popup, sets a cookie on the _instamaps.cat_ domain, manages a Google Analytics tracker and the default configure button popup\n\n## Building and testing the library\n\nInstall the dependencies\n```\nnpm install\n```\n\nBuilding the library\n```\nnpm run build-dev\n```\nTesting the library\n```\nnpm run lint\nnpm run test-unit\n```\nBuilding to release\n```\nnpm run build-min\n```\n\nTo see an extensive list of the available scripts you can take a look [here](https://github.com/geostarters/js-project-template#provided-scripts)\n\n## Acknowledgements\nThis cookie consent banner is heavily based on the [Insites cookieconsent](https://github.com/insites/cookieconsent) work and has been adapted to meet the requirements of the ICGC\n\n## License\nThis library is provided under the [MIT licence](http://opensource.org/licenses/MIT)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgencat%2FICGC-Cookie-GDPR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgencat%2FICGC-Cookie-GDPR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgencat%2FICGC-Cookie-GDPR/lists"}