{"id":21124504,"url":"https://github.com/zauberware/acceptcookies","last_synced_at":"2026-01-02T05:28:41.166Z","repository":{"id":79330026,"uuid":"108697450","full_name":"zauberware/acceptcookies","owner":"zauberware","description":"CraftCMS plugin for a drop in cookie acceptor.","archived":false,"fork":false,"pushed_at":"2018-05-26T00:27:37.000Z","size":47,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-21T05:26:59.205Z","etag":null,"topics":["accept-cookies","acceptors","cookie-acceptor","cookie-clicker","cookie-law","craft-cms-plugin","craft-plugin","craftcms-plugin","gdpr","gdpr-cookie","google-analytics"],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/zauberware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-29T01:52:35.000Z","updated_at":"2024-02-01T20:57:27.000Z","dependencies_parsed_at":"2023-02-27T04:45:39.730Z","dependency_job_id":null,"html_url":"https://github.com/zauberware/acceptcookies","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Facceptcookies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Facceptcookies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Facceptcookies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Facceptcookies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zauberware","download_url":"https://codeload.github.com/zauberware/acceptcookies/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243567225,"owners_count":20312003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["accept-cookies","acceptors","cookie-acceptor","cookie-clicker","cookie-law","craft-cms-plugin","craft-plugin","craftcms-plugin","gdpr","gdpr-cookie","google-analytics"],"created_at":"2024-11-20T04:16:45.780Z","updated_at":"2026-01-02T05:28:41.117Z","avatar_url":"https://github.com/zauberware.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🍪 acceptcookies - Craft 2 CMS plugin\nCraft 2 plugin for a drop in cookie acceptor to load GoogleAnalytics or other external resources only after the user accepts the Privacy Policy.\n\n**You don't use Craft ?** This [gist](https://gist.github.com/simonfranzen/8d832e2bc02dc6716aaf05c15fe34ca9) is a good starting point. In the end it's just plain HTML/CSS/JS! 👏\n\n## Features\n\n * Load GoogleAnalytics code only after accepting the notice.\n * Provide link to opt-out from analytics services.\n * Allows to load custom scripts like fonts, iframes, youtube videos, facebook, twitter plugin etc...\n * \"Refuse cookies\"-option for user\n * Set link to data policy page in settings.\n * Easy code to change style or behaviour.\n * No dependencies, just a few lines of HTML, JS and CSS\n\n\n## Installing\n\n1. Copy the `acceptcookies` directory into your `craft/plugins` directory\n2. Browse to Settings \u003e Plugins in the Craft CP\n3. Click on the Install button next to Accept Cookies\n\n## Usage\nSetup for plugin `http://yourdomain.com/admin/settings/plugins/acceptcookies`\n\n1. Change Google Analytics ID\n2. Add custom scripts\n3. Link to data policy page\n4. Let user reject the acceptor (-\u003e no analytics.js or custom scripts for user)\n5. Add `{{craft.acceptCookies.trackingCode|raw}}` in your base layout\n\nDisable acceptor for logged in users ?\n```php\n{% if not currentUser %}\n   {{ craft.acceptCookies.trackingCode|raw }}\n{% endif %}\n```\n\n### Opt-Out link in your data policy\n\nYou can provide your visitors a link to opt-out of google analytics. This is the link to deactivate the tracking:\n\n```\n\u003ca href=\"javascript:gaOptout();\"\u003eDeactivate Google Analytics\u003c/a\u003e\n```\n\n\n### Custom scripts under settings\n\n#### How to load custom font (e.g. Google-Font, Adobe TypeKit)\nLoad font from external services only after user accepts cookies. Use this example code to put into the custom script section of plugin settings.\n\n```\nvar head  = document.getElementsByTagName('head')[0];\nvar link  = document.createElement('link');\nlink.rel  = 'stylesheet';\nlink.type = 'text/css'; // if you include TypeKit then remove this line\nlink.id   = 'myfont'\n\n// change the link to an css here\nlink.href = 'https://fonts.googleapis.com/css?family=Roboto+Slab:400,300,700,100\u0026amp;subset=latin,latin-ext';\n\nlink.media = 'all';\nhead.appendChild(link);\n\n```\n\n#### How to load maps (e.g. Google-Maps)\nLoad maps from external services only after user accepts cookies. Use this example code to put into the custom script section of plugin settings.\n\n```\nvar head  = document.getElementsByTagName('head')[0];\nvar link  = document.createElement('script');\nlink.id  = 'maps';\n\n// change the API key in the maps link\nlink.src = 'https://maps.googleapis.com/maps/api/js?key=MAPS_API_KEY\u0026callback=initMap';\n\nlink.async = true;\nlink.defer = true;\nhead.appendChild(link);\n\n```\n\n#### How to load Google Tag Manager (gtag.js)\nLoad Google Tag Manager script only after user accepts cookies. Use this example code to put into the custom script section of plugin settings.\n\n```\nvar head  = document.getElementsByTagName('head')[0];\nvar gtagscript  = document.createElement('script');\ngtagscript.src= \"https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X\";\ngtagscript.async = true;\nhead.appendChild(gtagscript);\n\nwindow.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', 'UA-XXXXXXXXX-X');\n\n```\n\n#### How to facebook plugin\nLoad facebook plugin from external services only after user accepts cookies. Use this example code to put into the custom script section of plugin settings.\n\n```\n// Please use the snippets which facebooks give you. The language and API version from this snippet could be outdated.\n(function(d, s, id) {\n    var js, fjs = d.getElementsByTagName(s)[0];\n    if (d.getElementById(id)) return;\n    js = d.createElement(s); js.id = id;\n    js.src = \"//connect.facebook.net/de_DE/sdk.js#xfbml=1\u0026version=v2.5\u0026appId=YOUR_APP_ID\";\n    fjs.parentNode.insertBefore(js, fjs);\n  }(document, 'script', 'facebook-jssdk'));\n\n```\n\n### Experimental\n\n#### Load iframes after visitor accepts\n\nWrite the following iframe in this way:\n\n```\n\u003cdiv iframe-data=\"https://www.mylink.to/an/external/resource.mp4\"\u003e\n  You have to accept cookies to view this video.\n\u003c/div\u003e\n```\n\nThe script will parse all [iframe-data] - elements and converts them into iframes \n\n\nAfter the script is loaded it will call the function `initMap()`. Put your initialization logic for your maps in there.\n\n## Changelog\n\n* 2.0\n * GDPR ready!\n * Optimized sentence in cookie acceptor.\n * Experimental: Load iframe, only after user accepts cookie.\n\n\n* 1.1\n * Allow custom scripts\n * Added translations\n * Added sample to load fonts\n\n* 1.0\n  * Basic cookie acceptor. If accepted -\u003e triggers google analytics\n  * Simple config/settings\n  * Initial release!\n\n## Feature Requests\n* custom JS which loads after accepting cookies\n* custom css field and basic styling options\n\nFeel free to join !\n\n![zauberware technologies](https://avatars3.githubusercontent.com/u/1753330?s=200\u0026v=4)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzauberware%2Facceptcookies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzauberware%2Facceptcookies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzauberware%2Facceptcookies/lists"}