trackImpression

The trackImpression() method tracks the impressions of a content block and sends data about the content name, content piece and content target.

Syntax

const options = {
  piece: 'contentPiece',
  target: 'contentTarget',
  url: 'contentUrl',
  visitCustomVariables: { 1: { name: 'name', value: 'value' } },
  customDimensions: { 1: 'value', 2: 'value' },
};
await PiwikProSdk.trackImpression('contentName', options);

Parameters

contentName (string, required)

The name of the tracked content block.

options

Impression tracking options: an object containing five properties.

piece (string, optional)

The piece of the tracked content block. Example: a creative, banner or video.

target (string, optional)

The target of the tracked content block. Example: a link in the content block.

url (string, optional)

The URL for the tracked content block.

customDimensions

An object that specifies custom dimensions.

visitCustomVariables

An object that specifies visit custom variables.

Examples

To track the impression of a content block on your mobile app:

const options = {
  piece: 'banner',
  target: 'https://example.com/bikes/',
  visitCustomVariables: { 1: { name: 'name', value: 'value' } },
  customDimensions: { 1: 'value', 2: 'value' },
};
await PiwikProSdk.trackImpression('gravel bikes collection', options);

Notes

  • To track content impressions, this option needs to be turned on: Menu > Tag Manager > Tags > Piwik PRO (tracking code) > Data collection > Interactions with popups and content (on). Read more
  • Tracked impressions will be visible in Analytics > Reports > Content performance.

Related methods