verified
Retrieve opens from an email sendLearn how to retrieve the number of opens from an email send in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include WSProxy method.
WSProxy
var api = new Script.Util.WSProxy();
var cols = [
"SendID",
"EventDate",
"TriggeredSendDefinitionObjectID",
"SubscriberKey"
];
var result = api.retrieve("OpenEvent", cols, {
LeftOperand: {
Property: "SendID",
SimpleOperator: "equals",
Value: "1234567"
},
LogicalOperator: "AND",
RightOperand: {
Property: "SubscriberKey",
SimpleOperator: "equals",
Value: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
}
});
<script runat="server">
Platform.Load("core", "1");
var api = new Script.Util.WSProxy();
try {
var cols = [
"SendID",
"EventDate",
"TriggeredSendDefinitionObjectID",
"SubscriberKey"
];
var result = api.retrieve("OpenEvent", cols, {
LeftOperand: {
Property: "SendID",
SimpleOperator: "equals",
Value: "1234567"
},
LogicalOperator: "AND",
RightOperand: {
Property: "SubscriberKey",
SimpleOperator: "equals",
Value: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
}
});
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>//
{
"Status": "OK",
"RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"Results": [
{
"SendID": 1234567,
"SubscriberKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"EventDate": "2022-12-08T04:52:11.000",
"EventType": "Open",
"TriggeredSendDefinitionObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"BatchID": 0,
"Client": null,
"PartnerKey": null,
"PartnerProperties": null,
"CreatedDate": "0001-01-01T00:00:00.000",
"ModifiedDate": null,
"ID": 0,
"ObjectID": null,
"CustomerKey": null,
"Owner": null,
"CorrelationID": null,
"ObjectState": null,
"IsPlatformObject": false
}
],
"HasMoreRows": false
}
WARNING
SendID refers to the unique identifier for a specific send (JobID in the Send Log).
Reference
Ressources and references related to the current methods.
Official documentation
SOAP object