Skip to content

jerkovicl/ngx-gtm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ngx-Gtm

Build Release NPM Downloads

Angular library that automatically injects the script tag required to use Google Tag Manager.

Installation

npm:

npm install --save @jerkovicl/ngx-gtm

Yarn:

yarn add @jerkovicl/ngx-gtm

Compatibility

Version Angular Version
1.x.x >=17 <=18

Features

Usage

Import provideGtm from ngx-gtm and pass the required configuration when using it as a provider during application bootstrap.

import { provideGtm } from '@jerkovicl/ngx-gtm';

@NgModule({
  providers: [
    provideGtm({
      enabled: true,
      id: 'tag-id',
    }),
  ],
})
export class AppModule {}

// Or if you are using standalone bootstrap

bootstrapApplication(AppComponent, {
  providers: [
    provideGtm({
      enabled: true,
      id: 'tag-id',
    }),
  ],
});

Checkout the demo application in the demo folder for a working example.

The supported configuration parameters are:

Property Requirement Description
enabled Required Whether or not this module is enabled. Useful for disabling the script in development environments.
id Required Your Google Tag Manager tag Id. This is found in the Google Tag Manager settings page.

License

MIT