@ta-interaktiv/react-gtm

Component to add Google Tag Manager to projects.

Usage no npm install needed!

<script type="module">
  import taInteraktivReactGtm from 'https://cdn.skypack.dev/@ta-interaktiv/react-gtm';
</script>

README

Google Tag Manager React Component

Component to use Google Tag Manager on the page. This component should only be mounted when the GMT ID has be defined.

npm version

Installation

yarn add @ta-interaktiv/react-gtm

Usage

import React from 'react'
import { GoogleTagManager } from '@ta-interaktiv/react-gtm'

// more code ...

class YourComponent extends React.Component {
  componentDidMount() {
    // Get the Webseismo statistics object from Newsnet API here
    // NOT ACTUAL IMPLEMENTATION!
    this.setState({
      gtmObject: data.statistics.gtm,
      gtmId: data.gtmId
    })
  }

  render() {
    return (
      <GoogleTagManager
        gtmId={this.state.gtmId}
        article_id="000"
        {/* further properties ... */}
      />
    )
  }
}

Documentation

Can be found here.