Giter Site home page Giter Site logo

gopenso / glowcookies Goto Github PK

View Code? Open in Web Editor NEW

This project forked from manucaralmo/glowcookies

0.0 0.0 0.0 370 KB

GlowCookies ๐Ÿช - Powerful Cookie Consent Banner In JavaScript

Home Page: https://manucaralmo.github.io/glow-cookies-web/

License: GNU General Public License v3.0

CSS 20.29% JavaScript 79.71%

glowcookies's Introduction

Badge-glow jsDelivr hits (GitHub) GitHub contributors GitHub Repo stars

GlowCookies ๐Ÿช - Powerful Cookie Consent Banner In JavaScript

Simple and full automated cookies banner for any website. Complies with the new European regulations with GlowCookies. Activate and deactivate Google Analytics, Facebook Pixel, Hotjar (and coming soon) cookies whenever the user wishes, with just 1 click.

Foo

The cookies banner

How it works

You just have to install the code. When the user clicks on accept cookies, the google analytics tracking code, Facebook Pixel and/or Hotjar starts tracking. If the user rejects cookies, the tracking code will not start working.

How to use

Add this code to your html <head> or <body> tag.

<script src="https://cdn.jsdelivr.net/gh/manucaralmo/[email protected]/src/glowCookies.min.js"></script>
<script>
    glowCookies.start('en', { 
        style: 1,
        analytics: 'G-FH87DE17XF', 
        facebookPixel: '990955817632355',
        policyLink: 'https://link-to-your-policy.com'
    });
</script>

Banner styles

Now you can choose between these available banner styles:

  • Style 1, 2 or 3

Set style in config object glowCookies.start('en', { style: 3 })

Languages

Now you can choose between these available languages:

  • English (en)
  • Spanish (es)
  • German (de)
  • French (fr)
  • Norwegian (no)
  • Swedish (sv)
  • Danish (da)
  • Thai (th)
  • Slovak (sk)
  • Brazilian portugese (pt_BR)
  • Japanese (ja)
  • Italian (it)
  • Bulgarian (bg)
  • Turkish (tr)
  • Occitan (oc)
  • Dutch (nl)
  • Afrikaans (af)
  • Malagasy (mg)
  • Russian (ru)
  • Chinese Traditional (zh_TW)

Set language in the first parameter of glowCookies.start('en', { }) method.

Tracking options

These are the parameters that you can modify to add your tracking codes or custom scripts.

Parameter Type Values
analytics String Example: "G-FH87DE17XF" (Analytics tracking code)
facebookPixel String Example: "990955817632355" (Facebook Pixel code)
HotjarTrackingCode String Example: "990955817632355" (Hotjar tracking code)
customScript (Inline) Object Example: [{ type: 'custom', position: 'body', content: 'console.log('custom script');' }]
customScript (src) Object Example: [{ type: 'src', position: 'head', content: 'https://www.googletagmanager.com/gtag/js?id=G-FH87DE17XF' }]

Config Banner

These are the parameters that you can modify to change certain banner options

Parameter Type Values
policyLink String Example: "https://yourlink.com" (Your cookies policy link)
hideAfterClick Boolean (true or false) Default: true (Hide banner after Accept or Reject cookies)

Customize Banner

Now there are certain parameters that you can change to customize your banner.

Parameter Type Values
border String ("border" or "none") Default: "border"
position String ("left" or "right") Default: "left"
bannerDescription String Example: "We use our own and third-party cookies to personalize content and to analyze web traffic."
bannerLinkText String Example: "Read more about cookies"
bannerBackground String Example: "#FAFAFA" Example: "lightblue"
bannerColor String Example: "#000" Example: "blue"
bannerHeading String Example: "Use of cookies" Default: None
acceptBtnText String Example: "Accept cookies"
acceptBtnColor String Example: "#000" Example: "blue"
acceptBtnBackground String Example: "#fff" Example: "white"
rejectBtnText String Example: "Reject"
rejectBtnBackground String Example: "#000" Example: "blue"
rejectBtnColor String Example: "#fff" Example: "white"
manageColor String Example: "#fff" Example: "white"
manageBackground String Example: "#f2f2f2" Example: "blue"
manageText String Example: "Manage cookies"

Fully customized banner

<script src="https://cdn.jsdelivr.net/gh/manucaralmo/[email protected]/src/glowCookies.min.js"></script>
<script>
    glowCookies.start('en', { 
        style: 2,
        analytics: 'G-FH87DE17XF', 
        facebookPixel: '990955817632355',
        hideAfterClick: true,
        border: 'none',
        position: 'right',
        policyLink: 'https://google.es',
        customScript: [{ type: 'custom', position: 'body', content: `console.log('my custom js');` }],
        bannerDescription: 'banner desc',
        bannerLinkText: 'banner link text',
        bannerBackground: '#000',
        bannerColor: '#fafafa',
        bannerHeading: '<h2>Cookies</h2>',
        acceptBtnText: 'accept btn text',
        acceptBtnColor: 'green',
        acceptBtnBackground: 'red',
        rejectBtnText: 'reject btn text',
        rejectBtnBackground: 'lightblue',
        rejectBtnColor: 'blue',
        manageColor: 'white',
        manageBackground: 'blue',
        manageText: 'cookies text'
    });
</script>

Contribute

If you know any other language, please help translate.

  • Update the arrLang of the LanguageGC class in glowCookies.js (Add an entry in this fashion.)
  • Update language documentation in README.md
  • Create a pull request
en: {
    'bannerHeading': 'We use cookies',
    'bannerDescription' : 'We use our own and third-party cookies to personalize content and to analyze web traffic.',
    'bannerLinkText' : 'Read more about cookies',
    'acceptBtnText' : 'Accept cookies',
    'rejectBtnText' : 'Reject',
    'manageText' : 'Manage cookies'
}

Thanks for your help! ๐ŸŽ‰

Next steps

  • Advanced cookies management
  • Cookie settings

Request features

[email protected]

glowcookies's People

Contributors

manucaralmo avatar jurgenizer avatar pashkash avatar smaxx1337 avatar ueen avatar emilfabian avatar haroldao avatar djlimix avatar afbora avatar chrys-elrak avatar eduardorangell avatar masoo avatar manuel-steinberg avatar mejans avatar nedkamburov avatar ru-ka avatar wannaphong avatar sk5s avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.