trackContentInteractionNode
The trackContentInteractionNode() method tracks interactions with a content block in DOM Node and its children. The content block is an HTML element tagged with the data-track-content attribute or the piwikTrackContent class.
Syntax
trackContentInteractionNode(domNode[, contentInteraction])
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
Parameters
domNode (node, required)
The DOM Node that contains content blocks.
contentInteraction (string, optional)
The name of an interaction (Example: "click"). Default value: "Unknown".
Example
To track a "click" interaction with a content block in the DOM Node:
var domNode = document.querySelector("#add-image");
_paq.push([“trackContentImpressionsWithinNode”]);
_paq.push(["trackContentInteractionNode", domNode, "click"]);
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
This example shows how to track a "click" interaction with a signup button tagged with the onclick attribute:
<button onclick="function(){_paq.push(['trackContentInteractionNode', this, 'clicked']);}">
Sign up
</button>;
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
trackContentInteractionNode(domNode, contentInteraction?): void
Notes
- A content block is an HTML element tagged with the data-track-content attribute or the piwikTrackContent class.
- Always call the trackContentInteractionNode() method along with the trackContentImpressionsWithinNode() method. This will help you keep the tracking consistent.
Related methods
Updated 6 days ago