contentview¶
The contentview is related to the content web component as can be read in the web components documentation.
A contentview can be related to products, promotions or contents. This would require a viewType. For more information about the possible viewTypes, read the content related interactions documentation.
It is also possible to trigger a content interaction based on a contentview. For more information read about content interaction.
harvest.trackEvent({
"event":"contentview",
"data": {
"viewType": "promotionView",
"promotions": [{
"name": "Homepage header",
"creative": "Baseball jacket 50% off"
}]
}
});
The example above shows us how to track the contentview of a promotion on the homepage.
harvest.trackEvent({
"event":"contentview",
"data": {
"viewType": "productListView",
"products": [{
"id": "123sdfsfd123",
"name": "Baseball Jacket Grain",
"price": 99.95,
"list": "Featured items",
"position" : 1
},{
"id": "531234123",
"name": "Baseball Cap Grain",
"price": 49.95,
"list": "Featured items",
"position" : 2
}]
}
});
The above code is an example of tracking two products in the “Featured items” list that were in the viewport.
harvest.trackEvent({
"event":"contentview",
"data": {
"contentInteractionName": "bottomOfPageViewed"
}
});
The code above shows a way to trigger the “bottomOfPageViewed” content interaction.
Note
Since these examples are about the Javascript API, you will have to detect when an element is in view. You can also use our data attributes library, which will detect viewability on the elements.
For more information check the documentation of the contentview data-attributes: