# ta-react-tracking

> One-size-fits-all tracking component, supports Google Analytics, Google Tag Manager, WEMF NetMetrix and internal Newsnet tracker.

Latest version **1.0.4** (published 2017-06-01) · ISC license · 0 weekly downloads

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

## Install

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

## Health

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

Negative: deprecated.

## Facts

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

## Links

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

## Dependencies (6)

- [react](https://npm.io/package/react.md) ^15.3.2
- [d3-request](https://npm.io/package/d3-request.md) ^1.0.3
- [ta-react-ga](https://npm.io/package/ta-react-ga.md) ^1.0.0-0
- [ta-react-gtm](https://npm.io/package/ta-react-gtm.md) ^1.0.0-0
- [ta-react-wemftracking](https://npm.io/package/ta-react-wemftracking.md) ^1.0.0-0
- [ta-react-newsnettracker](https://npm.io/package/ta-react-newsnettracker.md) ^1.0.0

## 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

- 1.0.4 (latest) — 2017-06-01
- 1.0.3 — 2017-02-27
- 1.0.2 — 2017-02-27
- 1.0.1 — 2017-01-26
- 1.0.0 — 2016-11-25
- 1.0.0-0 — 2016-11-01

## README

# Tracking Component

## Deprecation Warning
This is the old version of this component. You should use the 
`ta-react-polymorphic-tracking`/soon-to-be 
`@ta-interaktiv/react-polymorphic-tracking` component instead.

One-size-fits-all tracking component, supports Google Analytics, Google Tag Manager, WEMF NetMetrix and internal Newsnet tracker.

Most of the configuration happens through calling 
`//www.${hostname}/api/sites/default`, so most properties are not required (but 
some of them are useful.)

## Installation

```bash
npm install ta-react-tracking --save
```

## Usage

```js
import Tracking from 'ta-react-tracking';

...

class YourComponent extends React.Component {
  render() {

    return (
      <Tracking articleId='123456' projectId='YourTestProject' />
    )
  }
}

```

## API – 1.0.0

### Props

Property | Type | Required | Description
------|----|---------|-----------
`articleId` | `string` | no | Newsnet article ID, for standalone projects that need to be tracked in CD as well.
`projectId` | `string` | no, but recommended | Freely definable project ID, used to identify single projects in WEMF/Netmetrix.
`rawSiteData` | `object` | no | Data object as provided by `//www.mandant.ch/api/sites/default`. If available, this component will not make its own request and use the provided data instead.

## Results

### WEMF/Netmetrix

Uses all the desktop tracker URLs from `//www.${hostname}/api/sites/default` by default. Appends `interactive/` and 
a project ID, if available, to the tracker URLs. Results in a list of tracking pixels of the form

```html
<img src="[Tracker URL]interactive/[projectId]?r=[Referer]&d=[Current Timestamp]" 
      style="position: absolute; visibility: hidden;"
      width="1"
      height="1"
/>
```

### Newsnet Tracker

Calls an URI using a JavaScript `image` object. Article ID is a number. Only rendered 
if a article number is provided.


### Google Analytics

This component will once call the standard GA invoking script:

```js
(function (i, s, o, g, r, a, m) {
      i['GoogleAnalyticsObject'] = r;
      i[r] = i[r] || function () {
          (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date();
      a = s.createElement(o),
        m = s.getElementsByTagName(o)[0];
      a.async = 1;
      a.src = g;
      m.parentNode.insertBefore(a, m)
    }(window,
      document,
      'script',
      'https://www.google-analytics.com/analytics.js',
      'ga'));
```

It will then for each Google Analytics tracker found in `http://www.${hostname}/api/sites/default` execute the following code:

```js
window.ga('create', [tracker.id], 'auto', [tracker.name]);
window.ga('[tracker.name].send', 'pageview');
```

### Google Tag Manager (GTM)

This component will once invoke the GTM script with the GTM ID found in `http://www.${hostname}/api/sites/default`:

```js
(function (w, d, s, l, i) {
      w[l] = w[l] || [];
      w[l].push(
        {
          'gtm.start': new Date().getTime(),
          event: 'gtm.js'
        }
      );
      let f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l !=
      'dataLayer' ?
        `&l=${
          l}` :
        '';
      j.async = true;
      j.src = `//www.googletagmanager.com/gtm.js?id=${  i  }${dl}`;
      f.parentNode.insertBefore(j, f);

    }(window, document, 'script', 'dataLayer', [GTM ID]));
```

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