1.2.0-beta.083f3e70 • Published 8 years ago

@ta-interaktiv/react-tracking v1.2.0-beta.083f3e70

Weekly downloads
60
License
ISC
Repository
gitlab
Last release
8 years ago

React Tracking

React component that grabs the current tracking data from the Newsnet API and sets up the appropriate trackers (WEMF, Google Tag Manager).

Installation

yarn add @ta-interaktiv/react-tracking

API

Table of Contents

Tracking

Extends React.PureComponent

Component to track visits to a website, accessing the Newsnet API for all tracking information. Currently supports GTM, WEMF and Webseismo. Additional Providers need to be added separately.

Parameters

  • props Props
    • props.articleId string? Article ID of the link article in the CD. If not available it will assume that content is being loaded in an iframe. So, yes, you can use this component without adding the articleId attribute. Make sure that you also pass an article ID when passing in the statistics configuration and GTM ID directly, otherwise WEMF won't track!
    • props.gtmId string? Google Tag Manager ID. If this isn't passed in, the component will fetch the necessary data from the Newsnet API.
    • props.statisticsConfigs Array<Statistic>? Array with statistics configuration objects as provided by Newsnet API. Together with the GTM ID, passing these in will prevent the component from making a network request.

Examples

Use the Newsnet API to get the necessary data

import Tracking from '@ta-interaktiv/react-tracking'
function YourComponent (props) {
  return (
    <div>
      <Tracking articleId='3352335' />
    </div>
  )
}

Add in data directly, circumventing network requests

// Access Newsnet API somewhere and get data
let newsnetData = fetch('m.tenant.ch/api/articles/111111/external_services')

render () {
  return (
    <Tracking articleId={111111}
              gtmId={newsnetData.configs.gtm_id}
              statisticsConfig={newsnetData.statistics}
    />
  )
}

Contributing

Code resides in /src.

This repository follows the Standard JS style. To fix your code, run

yarn run fix

JavaScript Style Guide

Type checking is provided by Flow.

yarn run flow

Styling

Styles reside in /style and/or /scss.

Testing

Test cases are provided using Storybook. Add test cases in /stories/index.js, and run them with

yarn run storybook

They will appear on http://localhost:9001.

Automated tests are written for Jest and can be found in /test. Run the test suite using

yarn run test

Transpiling

Babel is used to provide ES5 compatible code. To compile run

yarn run dist

Documentation

Documentation is generated from source, using both JSDoc comments as well as Flow type annotations. Update the documentation in this file using

yarn run docs
3.1.1

2 years ago

3.1.0

2 years ago

3.0.7

3 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.9-alpha.83

6 years ago

2.0.9-alpha.81

6 years ago

2.0.9-alpha.77

6 years ago

2.0.9-alpha.78

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.2

6 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.12

7 years ago

1.2.11

7 years ago

1.2.10

7 years ago

1.2.9

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago