verified
Retrieve a Triggered Send Definition's trackingLearn how to retrieve a Triggered Send Definition's tracking information in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include Core methods.
Retrieve all
var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var tsd = TriggeredSend.Init(customerKey);
var result = tsd.Tracking.Retrieve();
<script runat="server">
Platform.Load("core", "1");
try {
var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var tsd = TriggeredSend.Init(customerKey);
var result = tsd.Tracking.Retrieve();
Write(Stringify(result));
} catch (error) {
Write(Stringify(error));
}
</script>
[
{
"Client": {
"ID": 100000000
},
"CustomerKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"Name": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"ObjectID": "ac483156-585f-ed11-b844-48df37dc126a",
"LastSent": "2022-11-29T03:27:02.517",
"Sends": {
"Total": 1025
},
"Bounces": {
"Total": 0,
"HardBounces": 0,
"SoftBounces": 0,
"BlockBounces": 0,
"TechnicalBounces": 0,
"UnknownBounces": 0
},
"Clicks": {
"Total": 55,
"Unique": 3
},
"Opens": {
"Total": 100,
"Unique": 67
},
"Unsubscribes": {
"Unique": 0
}
}
]
Retrieve by timeframe (interval)
var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var tsd = TriggeredSend.Init(customerKey);
var config = {
prop: "Click",
start: "07-01-2022",
end: Now(),
interval: "day"
};
var result = tsd.Tracking.TotalByInterval.Retrieve(
config.prop,
config.start,
config.end,
config.interval
);
<script runat="server">
Platform.Load("core", "1");
try {
var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var tsd = TriggeredSend.Init(customerKey);
var config = {
prop: "Click",
start: "07-01-2022",
end: Now(),
interval: "day"
};
var result = tsd.Tracking.TotalByInterval.Retrieve(
config.prop,
config.start,
config.end,
config.interval
);
Write(Stringify(result));
} catch (error) {
Write(Stringify(error));
}
</script>
[
{
"RangeStart": "2022-03-26T00:00:00.000",
"RangeEnd": "2022-03-27T00:00:00.000",
"Total": 0,
"Unique": 0
}
]
Properties
Ordinal | Type | Required | Description |
---|---|---|---|
1 | String | Yes | Type of data to aggregate and return. Valid values include Send, Open, CLick, Bounce, and Unsubscribe. |
2 | DateTime | Yes | Start date for data period. |
3 | DateTime | Yes | End date for data period. |
4 | String | Yes | Interval used to aggregate data. Valid values include day and hour. |
Retrieve clicks
var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var tsd = TriggeredSend.Init(customerKey);
var filter = {
Property: "SendUrlID",
SimpleOperator: "equals",
Value: 12345
};
var result = tsd.Tracking.Clicks.Retrieve(filter);
<script runat="server">
Platform.Load("core", "1");
try {
var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";
var tsd = TriggeredSend.Init(customerKey);
var filter = {
Property: "SendUrlID",
SimpleOperator: "equals",
Value: 12345
};
var result = tsd.Tracking.Clicks.Retrieve(filter);
Write(Stringify(result));
} catch (error) {
Write(Stringify(error));
}
</script>
[
{
"SendUrlID": 12345,
"LinkName": "http://www.mywebsite.com",
"URL": "http://www.mywebsite.com/sfmc_id=%%subscriberid%%",
"Total": 7,
"Unique": 2
}
]
TIP
Remove the filter property in order to retrieve all the clicks.
Reference
Ressources and references related to the current methods.
Official documentation
Click columns
SOAP object
Help me turn coffee into code
This website is provided to you free of charge. However, a lot of time and effort are spent to write, test and mainain the code. Please consider supporting my work by buying me a cup of coffee.