Prepare Content Layouts and Site Pages to Use Consumption Analytics
Consumption analytics lets you track the usage and popularity of assets in sites. This is done automatically at the site level for all standard components, provided the asset consumption feature is enabled for the site.
To track consumption analytics for custom layouts and components, you must prepare content layouts and site pages to collect data within the site or sites where a component is used. The analytic information can then be collected when the site page renders and called in APIs for display in Oracle Content Management.
Several events can be collected for assets used on site pages.
Event Type | Description |
---|---|
load | The asset is referenced on the site page. |
view | The asset on the site page is scrolled into the browser viewport. |
play | A media asset on the site page has started to play. |
download | A download operation is initiated on the asset. |
Preparing Pages to Collect Data
There are two ways to prepare content layouts and site pages to collect data. You can augment the rendered asset markup on the page, or manually produce asset events with direct JavaScript calls.
Component Attributes
To automatically record asset consumption events, you can add special
data attributes to the rendered asset markup on the page. The
data-asset-operation
attribute instructs
the SCSRenderAPI to automatically produce analytic events. The value
syntax for the data-asset-operation
attribute is
<page-event>:<asset-id>:<asset-event>.
Multiple asset operations can be specified per attribute, separated
by a semicolon (;).
There are several parameters for the
data-asset-operation
attribute.
Parameter Name | Description |
---|---|
page-event | A page-event normally
corresponds to a DOM event, like click and
play events on elements. The supported page
events include:
|
asset-id | The id of the content item or digital asset. |
asset-event | One of the supported asset events
|
For example, the final markup of a simple content item might look like this:
<div data-asset-operation="view:COREBE60D5159507409B97E9B5CD27937B82:view">
Hello World!
</div>
The data-asset-operation
attribute in this markup
automatically generates a load event for the asset when this markup
appears on the page. Additionally, a view event will be recorded
when the item is scrolled into view in the browser viewport.
JavaScript API Calls
SCSRenderAPI.recordAssetOperation( assetId, assetEvent ) → {Boolean}
Name | Type | Required | Description |
---|---|---|---|
assetId | String | Yes | The id of the content item or digital asset. |
assetEvent | String | Yes | One of the supported asset events
|
This object returns a Boolean value of true if the event was accepted for recording, or false if not accepted.
For example, the following script records a play event when the button with the specified addetId is clicked.
<button onclick="javascript:SCSRenderAPI.recordAssetOperation('CONTBEAA53457DDE412B872D21DDC05FED5D', 'play')">Play the Associated Video</button>
Note:
Consumption analytics must be enabled in site settings before analytic information can be recorded.Additional Examples
The following is an example of adding
data-asset-operation
markup for digital
assets.
<img data-asset-operation="view:CONTBE5A53457DAE412B872C21DDC05FED5D:view" src="https://samples.mycontentdemo.com/content/published/api/v1.1/assets/CONTBE5A53457DAE412B872C21DDC05FED5D/Medium/Blog400px.jpg?channelToken=47c9fb78774d4485bc7090bf7b955632">
The following is an example of adding
data-asset-operation
markup for referenced
field types.
<ul data-asset-operation="view:COREBE60D5159507409B97E9B5CD27937B82:view">
<li>Name: Joe Bloggs</li>
<li>Age: 39</li>
<li>Photo: <img data-asset-operation="view:CONTBE5A53457DAE412B872C21DDC05FED5D:view" src="https://samples.mycontentdemo.com/content/published/api/v1.1/assets/CONTBE5A53457DAE412B872C21DDC05FED5D/Medium/Blog400px.jpg?channelToken=47c9fb78774d4485bc7090bf7b955632"></li>
<li>Video: <video data-asset-operation="view:CONTBE5A53457DAE412B872C21DDC05FED5D:view;play:CONTBE5A53457DAE412B872C21DDC05FED5D:play" src="https://samples.mycontentdemo.com/content/published/api/v1.1/assets/CONTBE5A53457DAE412B872C21DDC05FED5D/Medium/Blog400px.jpg?channelToken=47c9fb78774d4485bc7090bf7b955632"></video></li>
</ul>