# ta-react-gtm

> Component to add Google Tag Manager to projects.

Latest version **2.1.0** (published 2017-03-02) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ta-react-gtm
pnpm add ta-react-gtm
yarn add ta-react-gtm
bun add ta-react-gtm
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2017-03-02 |
| First published | 2016-11-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kaspar Manz |
| Maintainers | xeophin |
| Keywords | react, component, gtm |

## Links

- npm: https://www.npmjs.com/package/ta-react-gtm
- Repository: https://gitlab.com/ta-interactive/react-gtm
- Homepage: https://gitlab.com/ta-interactive/react-gtm#README
- Issues: https://gitlab.com/ta-interactive/react-gtm/issues
- npm.io page: https://npm.io/package/ta-react-gtm

## Dependencies (1)

- [react](https://npm.io/package/react.md) ^15.3.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2017-03-02
- 2.0.1 — 2017-02-28
- 2.0.0 — 2017-02-28
- 1.0.0-0 — 2016-11-01

## README

<a name="module_GoogleTagManager"></a>

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

**Version**: 2.1  

* [GoogleTagManager](#module_GoogleTagManager)
    * [module.exports](#exp_module_GoogleTagManager--module.exports) ⇐ <code>React.PureComponent</code> ⏏
        * [new module.exports()](#new_module_GoogleTagManager--module.exports_new)

<a name="exp_module_GoogleTagManager--module.exports"></a>

### module.exports ⇐ <code>React.PureComponent</code> ⏏
Set up the GTM tracking. Apart from a `noscript` fallback, this pretty
much doesn't render anything, but sets up the GTM dataLayer in the
constructor, loads the GTM.js script by Google while mounting and pushes
a pageview event into the dataLayer, using the passed-in props.

Apart from props.gtmId, all props are part of the statistics object
provided by the Newsnet API.

As this class extends `PureComponent`, it shouldn't be rerendered all the
time.

**Kind**: Exported class  
**Extends:** <code>React.PureComponent</code>  
<a name="new_module_GoogleTagManager--module.exports_new"></a>

#### new module.exports()

| Param | Type | Description |
| --- | --- | --- |
| props.gtmId | <code>string</code> | The GTM ID to use. |
| props.pagetype | <code>string</code> | The pagetype (e.g. 'article'). |
| props.category | <code>string</code> | The category of the article. |
| [props.subcategory] | <code>string</code> | The subcategory of the article. |
| [props.article_id] | <code>number</code> | The legacy article ID. |
| [props.premium] | <code>bool</code> | Whether this is a premium article. |


## Installation

```bash
yarn add ta-react-gtm
```

## Usage

```js
import GoogleTagManager from 'ta-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} {...this.state.gtmObject} />
    )
  }
}

```

---
_Source: https://npm.io/package/ta-react-gtm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
