Event API Responses

Requests sent to the Event API return JSON that contains information about any campaigns that are returned. A response from the Event API has the following structure.

{
    "campaignResponses": CampaignResponse[],
    "compiledCampaignTemplates": CompiledCampaignTemplate[],
    "campaignExplanations": CampaignExplanation[],
    "errorCode": number,
    "resolvedUserId": string,
    "persistedUserId": object,
    "eventDetails": eventDetails
}
Key Value Description
campaignResponses CampaignResponse[] An array of all campaigns returned in the event. For more information, see The CampaignResponse Object.
compiledCampaignTemplates CompiledCampaignTemplate[] An array of all campaign templates returned in the event. For more information, see The CompiledCampaignTemplates Object.
errorCode Number The error code. Possible values are: <ul><li> 0 : Success </li><li> 1 : Missing Encrypted UserId Parameter </li><li> 2 : Invalid Encrypted UserId Parameter</li><li>3 : Busy</li><li>4: Anonymous ID Correction</li><li>5: Invalid Event</li> </ul>
resolvedUserId String The primaryId of the resolved User. The primaryId is only returned if the Pipeline Identity Resolution feature is enabled for the tenant. For more information, see User Identity Mapping.
persistedUserId Object An object containing the encrypted user ID of the user. The Event API returns the persistedUserId only if Pipeline Identity Resolution isn’t enabled for the tenant and a primary user ID is specified in the event. For more information, see User Identity Mapping.
eventDetails eventDetails An object containing the event received by the server. This object is only returned if debug.explanations was sent with the event and the event was authenticated.

The CampaignResponse Object

The CampaignResponse object contains data associated with the campaigns returned from an event.

{
    "type": string,
    "campaignId": string,
    "campaignName": string,
    "campaignType": string,
    "experienceId": string,
    "experienceName": string,
    "experienceSourceCode": string,
    "state": string,
    "displayMode": string,
    "redirectUrl": null,
    "saveParameters": boolean,
    "hidePageBeforeRedirect": boolean,
    "campaignJavascriptContent": null,
    "javascriptContent": null,
    "userGroup": string,
    "googleAnalyticsConfig": null,
    "messages": [],
    "pageChanges": [],
    "templateNames": string[],
    "serverSideMessages": ServerSideMessage[],
    "payload": payload
}
Key Value Description
type String The type of campaign returned. The value of type is "c" for server-side campaigns and "ng" for web campaigns.
campaignId String The ID of the campaign returned.
campaignName String The name of the campaign returned.
campaignType String The type of the campaign returned. The value of campaignType is "ServerSide" for server-side campaigns and "Web" for web campaigns.
experienceId String The ID of the experience returned.
experienceName String The name of the experience returned.
state String The state of the campaign returned. The value of state can be "Published", "Disabled", or "Testing" depending on the campaign state.
displayMode String Deprecated. This object is only returned for server-side campaigns and its value is always "Personalized".
redirectUrl Null Deprecated. This object is only returned for server-side campaigns.
saveParameters Boolean Deprecated. This object is only returned for server-side campaigns and is always set to false.
hidePageBeforeRedirect Boolean Deprecated. This object is only returned for server-side campaigns and is always set to false.
campaignJavascriptContent Null Deprecated. The campaignJavascriptContent object is always set to null.
javascriptContent Null Deprecated. This object is only returned for server-side campaigns and is always set to null.
userGroup String The user group of the campaign experience returned. The value of userGroup can be either "Default" or "Control".
googleAnalyticsConfig Null Deprecated. This object is only returned for server-side campaigns and is always set to null.
messages Empty array Deprecated. This object is only returned for server-side campaigns and is always set to [].
pageChanges Empty array Deprecated. This object is only returned for server-side campaigns and is always set to [].
templateNames String array An array of the template names used in the experience. This object is only returned for web campaigns.
serverSideMessages ServerSideMessage[] An array of messages returned for a server-side campaign. This object is only returned for server-side campaigns. The event must be sent with source.channel set to "Server" in order to return serverSideMessages. For more information, see ServerSideMessage object.
payload payload The payload object that the campaign returns. The payload object always includes the campaign, experience, and userGroup fields, along with other user defined fields. For more information, see Template Server Typescript. Note: The value of campaignResponse.payload.userGroup can either be "Test" or "Control".

The ServerSideMessage Object

The ServerSideMessage object contains data associated with serverSideMessages returned in a campaignResponse.

For server-side campaigns, an array of ServerSideMessage objects is returned that contains information about the data returned for the server-side campaign message. The event must be sent with source.channel set to "Server" in order to return serverSideMessages. For more information on configuring server-side campaigns, see Server-Side Campaigns.

{
    "type": string,
    "id": string,
    "data": string,
    "targetName": string,
    "containsDynamicContent": boolean,
    "promotedItemKeys": PromotedItem[] | null,
    "campaignState": string,
    "dataMap": dataMap
}
Key Value Description
type String The type of message that is returned. For a ServerSideMessage, the type is always "evg_md".
id String The ID of the message that is returned.
data String Deprecated. Its value is always "{}".
targetName String The name of the target for the ServerSideMessage.
containsDynamicContent Boolean The value returned is true if the message contains any dynamic content, and false if the message doesn’t contain dynamic content.
promotedItemKeys PromotedItem[] | null If the message contains promoted items, promotedItemKeys is an array of promoted items. Otherwise its value is null. Each PromotedItem returned contains the type of the item returned and the _id of the item returned.
campaignState "Published", "Disabled", or "Testing" The state of the campaign returned.
dataMap dataMap An object containing the key value pairs defined in the campaign.

Example Values

The following is an example of a value returned in the promotedItemKeys object:

{
    type: "p",
    _id: "123"
}

The following is an example of a value returned in the dataMap object:

dataMap: {
    "myText": "helloWorld",
    "myNumber": "1",
    "myPromotedContent": [
        {
            "type": "p",
            "_id": "123"
        },
        {
            "type": "p",
            "_id": "456"
        }
    ]
}

For keys with type "Promoted Content", the full value of each item is returned unless the "Item IDs only" option is enabled in the message settings. For more information on configuring server-side campaigns and the returned dataMap object, see Server-Side Campaigns.

The CompiledCampaignTemplates Object

The CompiledCampaignTemplates object contains data associated with campaignTemplates returned in an event.

An event response returns an array of any compiledCampaignTemplates used in a campaignResponse. The compiledCampaignTemplates object contains information about the campaign templates.

{
    "id": string,
    "name": string | null,
    "bundle" string
}
Key Value Description
id String The ID of the template.
name String or null The name of the template.
bundle String The stringified client-side code used to render the template.

The CampaignExplanations Object

The CampaignExplanations Object contains data associated with campaignExplanations returned in an event.

The campaignExplanations object returns in an event only if debug.explanations is true in the event payload. It contains additional information about why campaigns did or didn’t return in the event response. It’s only returned if the event request is authenticated.

{
    "class": string,
    "campaignId": string,
    "campaignName": string,
    "experienceId": string,
    "experienceName": string,
    "messageId": string,
    "explanationMessage": string,
    "context": string
}
Key Value Description
class String Information of the type of explanation that is returned.
campaignId String The ID of the campaign that the explanation is for.
campaignName String The name of the campaign that the explanation is for.
experienceId String The ID of the experience that the explanation is for.
experienceName String The name of the experience that the explanation is for.
messageId String The ID of the message that the explanation is for.
explanationMessage String A message containing the reason for not returning the campaign in the response.
context String A string containing the campaign name, campaign ID, experience name, and experience ID for the message that isn't returned in the response.

See Also