7.4.0 • Published 2 months ago

@financial-times/n-tracking v7.4.0

Weekly downloads
1,133
License
MIT
Repository
-
Last release
2 months ago

@financial-times/n-tracking CircleCI

This package provides tracking initialisation for FT.com. On the client-side it configures o-tracking (which is used to capture and send tracking events to Spoor) and for the server-side it provides components which render fallback tracking pixels .

Getting started

This package is for client-side and server-side use and is distributed on npm.

npm install -S @financial-times/n-tracking

After installing the package you can import the tracking component into your code:

Client-side integration

On the client-side this package can be used to configure o-tracking, setup click tracking, and send a page view event.

import * as nTracking from '@financial-times/n-tracking';

const oTracking = nTracking.init(options);

nTracking.broadcast('oTracking.event', {
  category: 'page',
  action: 'custom-event',
});

To initialise the component you'll need to provide it with several configuration options.

Server-side integration

On the server-side a JSX component embeds tracking pixels into the page which send page view events for any visitors which do not support JS or fail to cut the mustard.

const { CoreTracking } = require('@financial-times/n-tracking');

<CoreTracking {...options} />

To initialise the component you'll need to provide it with several configuration options.

Client-side API

init(options)

Configures o-tracking with the given options, triggers a page view event, initialises click tracking, and returns the instance of o-tracking.

broadcast(name, data)

Creates a CustomEvent with the given name and data and dispatches it from the document <body> element. It is intended to be used to trigger oTracking.event events.

trackers.customTrackerName()

TODO: custom tracking events to be used across FT.com

Server-side API

<CoreTracking />

Renders a <noscript> and inline <script> element to embed fallback tracking pixels into the page which can be used when the client-side JS fails to run. It accepts the same options as the client-side code.

Options

PropertyTypeRequiredDescription
appContextObjectYesFT.com App Context data describing the current page which will be appended to all captured events.
extraContextObjectNoAdditional data describing the current page which will be appended to all captured events.
pageViewContextObjectNoAdditional data to append to the page view event only

Automatically inferred data

  • Marketing query string parameters inc. cost-per-click and segment IDs
  • User data inc. layout, screen orientation, and connection type
  • Error page parameters inc. error code and error message
7.4.0

2 months ago

7.3.0

5 months ago

7.2.2

6 months ago

7.2.1

6 months ago

7.2.0

7 months ago

7.1.1

8 months ago

7.2.3

5 months ago

6.3.0

1 year ago

6.2.0

1 year ago

7.0.0

1 year ago

7.1.0

11 months ago

6.1.0

1 year ago

6.1.0-beta.1

1 year ago

6.0.0

2 years ago

5.2.0

2 years ago

5.1.0

2 years ago

5.0.0

2 years ago

4.3.1

2 years ago

4.3.0

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.0

2 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.1.0-beta.2

4 years ago

1.0.0

4 years ago

1.1.0-beta.1

4 years ago

1.0.0-beta.5

4 years ago

1.0.0-beta.4

4 years ago

1.0.0-beta.3

5 years ago

1.0.0-beta.2

5 years ago

1.0.0-beta.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago