Skip to content

peach-collector.js events documentation

Currently, these events are available:


Page events

  • sendPageViewEvent(recommendation_id, page_uri, referrer)
  • sendReadMoreEvent(id, context, metadata)
  • sendArticleStartEvent(article_id, context, metadata)
  • sendArticleEndEvent(article_id, time_spent, completion_ratio, position_ratio, context, metadata)

sendPageViewEvent() can be called without parameters, page_uri and referrer will be retrieved from the window


Media events

  • sendMediaPlayEvent
  • sendMediaPauseEvent
  • sendMediaSeekEvent
  • sendMediaStopEvent
  • sendMediaEndEvent
  • sendMediaHeartbeatEvent
  • sendMediaVideoModeChangedEvent
  • sendMediaAudioModeChangedEvent
  • sendMediaAudioChangedEvent
  • sendMediaLikeEvent
  • sendMediaShareEvent

Those functions can be called using different signatures:
- (media_id, context, properties, metadata)
- (html_media_element, media_id, context, properties, metadata)
- (html_media_element)

By providing an HTML Media Element to the PeachCollector, the event will be created by retrieving available information in the element.

Defining a media event manually:

var component = _pc.EventContextComponent('player', 'myPlayer', '1.0');
var context = _pc.mediaContext('recommendation0001', 'recommendation', null, window.location.href, null, component);
var props = _pc.EventProps().setPlaybackPosition(0);
var metadata = _pc.EventMetadata('video', 'ondemand', null, null, 30.5};
_pc.sendMediaPlayEvent('my_media001', context, props, metadata);

Relying only on the HTML Media Element:

var media_element = evt.target;
_pc.sendMediaPlayEvent(media_element);

Providing an HTML Media Element and completing the information manually:

var media_element = evt.target;
var component = _pc.EventContextComponent('player', 'myPlayer', '1.0');
var context = _pc.mediaContext('recommendation0001', 'recommendation', null, window.location.href, null, component);
_pc.sendMediaPlayEvent(media_element, 'my_media001', context);

Recommendation events

  • sendRecommendationHitEvent(recommendation_id, item_id, hit_index, page_uri, source, referrer, component)
  • sendRecommendationLoadedEvent(recommendation_id, items, page_uri, referrer, source, component);
  • sendRecommendationDisplayedEvent(recommendation_id, items_displayed, page_uri, referrer, source, component);

Custom Events

  • sendCustomEvent(type, id, context, properties, metadata)