2.0.1 • Published 4 years ago

easily-gtm v2.0.1

Weekly downloads
73
License
MIT
Repository
github
Last release
4 years ago

Simple Google Tag Manager

Simple GTM library for Angular 7+

Open issues licence version angular

Install

  • Run npm install easily-gtm --save-dev
  • Create a attribute on environment config:
export const environment = {
  production: false,
  tagManagerId: 'GTM-XXXXXXX',
};
  • Import on main.js:
import { EasilyGtmService } from 'easily-gtm/easily-gtm.service';
  • Implement function generate on <header> and <body>:

    This function create the script and no-script tags.

EasilyGtmService.generate(environment.tagManagerId);

Using

This library has one function only: push

  • Import the library
import { EasilyGtmService } from 'easily-gtm/easily-gtm.service';
  • Include on components' constructor
constructor(private egtm: EasilyGtmService) {}
  • Use the method:
this.egtm.push('vpageview', {'page': '/teste'});

The mothod has two params: event, params:

Event

This attribute is a String and receive the event.

Example: vpageview, ga-event, ga-exception

Params

This attribute is a object with this format:

{
  'page': 'value'
}

or

{
  'category': 'your category',
  'action': 'your action',
  'label': 'your label'
}

or

{
  'category': 'your category',
  'action': 'your action',
  'value': 'your value'
}

npm.ionpm.ionpm.ionpm.ionpm.ionpm.ionpm.ionpm.io

2.0.1

4 years ago

2.0.0

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.0

5 years ago