ngx-gtm-cookie-consent
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

ngx-gtm-cookie-consent

npm Build Status Quality Gate Status

An Angular library to comply with the GDPR and the latest european law regarding cookies 🍪

This project is work-in-progress. Features and Documentation are probably not complete.

Usage

  1. Install dependencies

npm install --save ngx-gtm-cookie-consent ngx-cookieconsent cookieconsent

or

yarn add ngx-gtm-cookie-consent ngx-cookieconsent cookieconsent

  1. Add the following to your angular.json:
{
    "assets": [
        {
            "glob": "**/cookie-consent.js",
            "input": "node_modules/ngx-gtm-cookie-consent/static/js",
            "output": "./ngx-gtm-cookie-consent"
        }
    ],
    "styles": [
        "node_modules/cookieconsent/build/cookieconsent.min.css",
        "node_modules/ngx-gtm-cookie-consent/static/css/main.css"
    ],
    "scripts": [
        "node_modules/cookieconsent/build/cookieconsent.min.js"
    ]
}
  1. Add a script in your index.html head section:
<script src="ngx-gtm-cookie-consent/cookie-consent.js"></script>
  1. Create a cookieConfig object (see ngx-cookieconsent)

  2. Add imports to your AppModule:

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    NgcCookieConsentModule.forRoot(cookieConfig),
    CookieModule.forRoot({
      gtmContainerId: 'GTM-XXXYYY', // Your Google Tag Manager container ID
      enable: true, // Control this from your environment files
      cookieConsentPopUpConfig: cookieConfig
    })
  ]
})
export class AppModule { }
  1. Create a new trigger in Google Tag Manager

Trigger

  1. Use the new trigger to fire tags (e.g. for Google Analytics)

Tag

i18n support

You can change the content of the cookie banner after the initial setup, for example to react to a locale change by the user. The CookieConsentService provides the function setCookieConsentConfig() which can be used to provide an updated config object.

Readme

Keywords

none

Package Sidebar

Install

npm i ngx-gtm-cookie-consent

Weekly Downloads

0

Version

0.2.0

License

none

Unpacked Size

409 kB

Total Files

30

Last publish

Collaborators

  • exportarts_enzo