Access custom code contextual information

Harness event data from the payload object to customize user experiences and perform event-based functions

When a placement executes custom code as an experience or a trigger executes a Custom Code action, you can access the payload object containing contextual information related to the event that triggered the code execution. This payload allows you to employ relevant data to customize the user experience, enhance analytics, and perform other functions based on the event details.

Common Use Cases

Property Use Case
payload.analytics.outcomeId
  • Reporting
payload.placementId
  • Reporting
  • Obtaining a reference to the <div> element in which the experience is nested


Retrieve contextual information

Follow these steps to retrieve contextual information:

  1. In the custom code block in your JWP dashboard, add the following code.

    Be sure to replace the <PROPERTY> placeholder with the payload property to be retrieved.
    console.log(payload.<PROPERTY>);
    

  2. Use the value of the property within the custom code.


payload reference

payload: {
  placementId: "abcd1234",
  analytics: {
    embedId: "cd3e43f3",
    evaluationId: "j4hncv8a",
    outcomeId: "kn349ng3"
  },
  eventEmitter: {<various>},
  eventEmitterType: {<various>},
  eventPayload: {<various>}
}
Property Description
analytics object Collection of unique identifiers related to a Dynamic Strategy Rule branch and its conditions

See: analytics
eventEmitter object (Trigger-executed custom code) Instance of the experience emitting the event
eventEmitterType string (Trigger-executed custom code) Type of experience emitting the event

Possible Values:
  • player
eventPayload object (Trigger-executed custom code) Event metadata included in the underlying event

For example, if the event is a JWP ad Impression, eventPayload would be the event metadata received when using jwplayer.on('adImpression', function(e) {...}), where e is the event metadata.
placementId string Unique identifier for a placement

This is the primary key used when embedding a placement within a publisher's page.

See also: Placement ID

analytics

Property Description
embedId string Unique identifier generated for each placement instance that is embedded on a page

See also: Placement Embed ID
evaluationId string Unique identifier generated for each evaluation of a placement on a page

See also: Placement Evaluation ID
outcomeId string Unique identifier for a strategy outcome

See also: Strategy Outcome ID

© 2007-2024 Longtail Ad Solutions, Inc.