The NPO object

Once the NPO tag has been loaded it will offer an NPO object on the page. This object contains the following methods.


NPO.page(extraLabels)

Sends a pageview. Information in extraLabels can overwrite fields from the page’s NPOlabels.


NPO.view(extraLabels)

Sends a contentview. Mostly used in single page apps to track navigation. Information in extraLabels can overwrite fields from the page’s NPOlabels.


NPO.click(extraLabels)

Sends a click. The NPOLabels already present in the page will be added to the click event. Information in extraLabels can overwrite fields from the page’s NPOlabels. The extraLabels should contain at least a type field, with one of ‘exit’, ‘download’, ‘action’ or ‘navigation’ as value. A name field can be provided to indicate what has been clicked. If not provided the pagename will be used.

<script>

	NPOlabels = {
		pagina: 'home',
		omgeving: 'dev',
		merkId: 1,
		merk: 'npoportal',
		platform: 'site',
		niveau1: 'nivo1',
		merkType: 'standalone'
	};
	
	NPO.click({
		type: 'action',
		name: 'socialbutton',
		niveau1: 'playericons'
	});

</script>

The example above will generate a click containing all labels from the page, but with a different niveau1 value.


NPO.recorder(mid)

Returns a recorder objects that can be used to track player events for a certain media id, passed in as it’s only parameter mid.

The following methods are available

var recorder = NPO.recorder('1234_MID');

recorder.load() // call when the video stream is loaded
recorder.adStart() // call when an ad is started
recorder.adPause() // call when an ad is paused
recorder.adResume() // call when an ad is resumed
// recorder.adTime() => available but not implemented
// recorder.adSkip() => available but not implemented
recorder.adComplete() // call when an ad is completed
recorder.start() // call when the playback of the video is started
recorder.pause() // call when the video pause event is triggered
recorder.resume() // call when the video resume event is triggered
recorder.seek(from, to) // call when the position of the video progress is moved
recorder.complete() // call when the video complete event is triggered
recorder.fullScreen() // call when the video player fullscreen event is triggered
recorder.windowed() // call when the video fullscreen is cancelled
recorder.time(seconds, duration) // call every 30 seconds to send a waypoint/heartbeat to topspin
// recorder.volume() => available but not implemented
// recorder.mute() => available but not implemented

NPO.setUser(user)

Adds user information to subsequent events. The user parameter has the following form:

NPO.setUser({
	nopId: '',
	profielId: '',
	npoType: ''
})

NPO.clearUser()

Removes the user information.


NPO.mediaRecommender(panel, source)

Used to group recommendations based on a certain source and provides a way to generate offer and choice events for these items.

Parameters: panel: Identification of the panel or group in which recommendations are shown. Falls back to the string ‘default’ if not provided. source: Identification of the item on which the recommendations are based.

Returns: a recommender object

Recommender object

A object containing an offer and a choice method.

recommender.offer(  
  {recommender: 'ts-base', midRef: 'VPWON_1250237'}, // Offered recommendation
  2,   // Position in the group, zero based
  10,  // Amount of recommendations in the group 
  [EL] // Optional html Element that will be monitered
);

If an element has been provided as fourth argument, the offer event will not be sent until the element is visible to the visitor.

recommender.choice(
  {recommender: "ts-base", "midRef": "VPWON_1250237"}, // Chosen recommendation
  2,   // Position in the group, zero based
  10,  // Amount of recommendations in the group 
  action  // Optional.
  // Either an url to the result, it will be enriched with parameters so the choice will be measured on the result page.
  // Or action can be a function that will be called when the choice is made
);

Media recommendations have two required fields; recommender and midRef.


NPO.editorialRecommender(panel, source)

Same as the mediaRecommender, but meant to be used for handmade or editorial recommendations. Editorial recommendations have two required fields; editorial and midRef.


NPO.searchRecommender(panel, query)

Same as the other recommenders, but meant to be used for search result. The source parameter has been replaced by query so the text used to find these items can be measured. Search results have two required fields; engine and id.