trackInteraction
The trackInteraction() method tracks the interactions with a content block and sends data about the content name, interaction type, piece, and target.
Syntax
const options = {
piece: 'contentPiece',
target: 'contentTarget',
visitCustomVariables: { 1: { name: 'name', value: 'value' } },
customDimensions: { 1: 'value', 2: 'value' },
};
await PiwikProSdk.trackInteraction('contentName', 'interaction', options);Parameters
contentName (string, required)
The name of the tracked content block.
interaction (string, required)
The type of interaction with the content block. Example: click.
options
Interaction tracking options: an object containing four 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.
customDimensions
An object that specifies custom dimensions.
visitCustomVariables
An object that specifies visit custom variables.
Examples
To track the interaction with 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.trackInteraction('gravel bikes collection', 'click', options);Notes
- To track interactions with content, 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 interactions will be visible in Analytics > Reports > Content performance.
Related methods
Updated about 5 hours ago