JSPM

@mathu01/gdpr-consent

1.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q18688F
  • License MIT

GDPR banner to comply with the European cookie law. Inspired by tarteaucitronjs.

Package Exports

  • @mathu01/gdpr-consent
  • @mathu01/gdpr-consent/webpack.config.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mathu01/gdpr-consent) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NPM version QC Checks

gdpr-consent.js

Comply to the european cookie law. Inspired by AmauriC/tarteaucitron.js

What is this script?

The european cookie law regulates the management of cookies and you should ask your visitors their consent before exposing them to third party services.

Clearly this script will:

  • Disable all services by default,
  • Display a banner on the first page view and a small one on other pages,
  • Display a panel to allow or deny each services one by one,
  • Activate services on the second page view if not denied,
  • Store the consent in a cookie for 365 days.

How to use

<link rel="stylesheet" href="gdpr-consent.css" />
<script type="text/javascript" src="gdpr-consent.js"></script>
<script type="text/javascript">
    GDPRConsent.init({
        hashtag: "#tarteaucitron" /* Open the panel with this hashtag */,
        cookieName: "tarteaucitron" /* Cookie name */,
        timeExpire: 31536000000 /* Cookie expiration time */,
        websiteName: "Les Jours" /* The name of the Website */,
        AcceptAllCta: true /* Show the accept all button*/,
        moreInfoLink: true /* Show more info link */,
        mandatory: false /* Show a message about mandatory cookies */,
    });
</script>

Add services

<script type="text/javascript">
    /* Initialize gdprconsent.js job array */
    GDPRConsent.job = GDPRConsent.job || [];

    /* Add Google Tag Manager */
    GDPRConsent.user.googletagmanagerId = "GTMID";
    GDPRConsent.job.push("googletagmanager");

    /* Add Google Analytics (gtag.js) */
    GDPRConsent.user.gtagUa = "GAID";
    GDPRConsent.user.gtagInitOptions = {};
    GDPRConsent.job.push("gtag");

    /* Add Socials Sharing Services : Twitter & Facebook */
    GDPRConsent.job.push("twitter");
    window.fbAsyncInit = function () {
        FB.init({});
    };
    GDPRConsent.job.push("facebook");

    /* Add Vidéos */
    GDPRConsent.job.push("vimeo");
    GDPRConsent.job.push("youtube");
</script>