@ta-interaktiv/react-tracking v1.2.0-beta.083f3e70
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-trackingAPI
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
propsPropsprops.articleIdstring? 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 thearticleIdattribute. 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.gtmIdstring? Google Tag Manager ID. If this isn't passed in, the component will fetch the necessary data from the Newsnet API.props.statisticsConfigsArray<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 fixType checking is provided by Flow.
yarn run flowStyling
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 storybookThey 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 testTranspiling
Babel is used to provide ES5 compatible code. To compile run
yarn run distDocumentation
Documentation is generated from source, using both JSDoc comments as well as Flow type annotations. Update the documentation in this file using
yarn run docs2 years ago
2 years ago
3 years ago
4 years ago
4 years ago
4 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago