1.0.45 • Published 9 months ago

react-gtm-ts v1.0.45

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

🚀 react-gtm-ts

This is a library to facilitate the implementation of Google Tag Manager.

Installation

npm install react-gtm-ts
or
yarn add react-gtm-ts

Usage

Add ReactTagManager.init passing GTM code in app or _app (nextjs):

import { ReactTagManager } from 'react-gtm-ts';

import { NextPageWithLayout } from '@Core/types/next';
import type { AppProps } from 'next/app';

type AppPropsWithLayout = AppProps & {
  Component: NextPageWithLayout;
};

ReactTagManager.init({
  code: 'GTM-XXXX', // GTM Code
  debug: false, // debug mode (default false)
  performance: false, // starts GTM only after user interaction (improve initial page load)
});

function MyApp({ Component, pageProps }: AppPropsWithLayout) {
  return <Component {...pageProps} />;
}

export default MyApp;

Now just use the ReactTagManager.action for the actions passing the event and the variables (optional)

import { ReactTagManager } from 'react-gtm-ts';

import { NextPageWithLayout } from '@Core/types/next';

const Home: NextPageWithLayout = () => {
  return (
    <div>
      <button
        type="button"
        onClick={() => {
          ReactTagManager.action({
            event: 'click_all_button',
            clickText: 'login',
          });
        }}
      >
        login
      </button>
    </div>
  );
};

export default Home;

Learn More

To learn more about Google Tag Manager, take a look at the following resource documentation.

1.0.45

9 months ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.40

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.33

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago