3.0.1 • Published 15 days ago

@scaleway/use-gtm v3.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
15 days ago

@scaleway/use-gtm

A tiny provider to handle Google Tag Manager in React

Install

$ pnpm add @scaleway/use-gtm

Usage

Basic

import GTMProvider, { useGTM } from '@scaleway/use-gtm'

const Page = () => {
  const { sendGTM } = useGTM()

  sendGTM?.({
    hello: 'world
  })

  return <p>Hello World</p>
}

const App = () => (
  <GTMProvider id="testId">
    <Page />
  </GTMProvider>
)

With injected events

import GTMProvider, { useGTM } from '@scaleway/use-gtm'

const events = {
  sampleEvent: (sendGTM?: SendGTM) => (message: string) => {
    sendGTM?.({
      event: 'sampleEvent',
      hello: message,
    })
  },
}

const Page = () => {
  const { events } = useGTM()

  events.sampleEvent?.('world')

  return <p>Hello World</p>
}

const App = () => (
  <GTMProvider id="testId">
    <Page />
  </GTMProvider>
)

With global setter

import GTMProvider, { sendGTM } from '@scaleway/use-gtm'

const Page = () => {
  sendGTM?.({
    hello: 'world
  })

  return <p>Hello World</p>
}

const App = () => (
  <GTMProvider id="testId">
    <Page />
  </GTMProvider>
)
3.0.1

15 days ago

3.0.0

2 months ago

2.0.2

10 months ago

1.3.4

1 year ago

1.3.3

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.3.2

1 year ago

1.3.1

2 years ago

1.2.3

2 years ago

1.3.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago