Ngx-Gtm

September 24, 2025 ยท View on GitHub

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

VersionAngular Version
1.x.x>=17 <=19
1.4.x>=17 <=20

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:

PropertyRequirementDescription
enabledRequiredWhether or not this module is enabled. Useful for disabling the script in development environments.
idRequiredYour Google Tag Manager tag Id. This is found in the Google Tag Manager settings page.

License

MIT