How to fetch email marketing insights data from Marketo using API?
## How to Fetch Email Marketing Insights Data from Marketo Using API
### Introduction
Marketo's API does not provide a direct endpoint for querying email performance reports. However, the data components of these reports (email delivery, bounce, open, and click) can be retrieved through the **Get Lead Activities** endpoint.
### Querying Lead Activities Endpoint
To fetch email marketing insights data, follow these steps:
1. **Get Activity Types:** Query the **Get All Activity Types** endpoint to obtain the internal IDs of the following activity types:
- Send Email
- Email Delivered
- Email Bounced
- Unsubscribe Email
- Open Email
- Click Email
2. **Get Paging Token:** Call the **Get Activities Paging Token** endpoint to specify the earliest datetime for retrieving activities.
3. **Query Lead Activities:** Use the **Get Lead Activities** endpoint with the following parameters:
- `nextPageToken`: The datetime specified in Step 2
- `activityTypeIds`: The IDs of the activity types obtained in Step 1
### Processing Results
The response from the **Get Lead Activities** endpoint will be an array of objects containing activity data. Each item can be filtered to a specific email based on the `primaryAttributeValue` property.
```
{
"id":7370416,
"marketoGUID":"7170506",
"leadId":291305,
"activityDate":"2017-12-17T00:00:00Z",
"activityTypeId":11,// #11 = `Click Email`
"campaignId":1790,
"primaryAttributeValueId":1638,
"primaryAttributeValue":"EMAIL_NAME",// Name of the Email as seen in Marketo
"attributes":[
// …
]
}
```
### Conclusion
By leveraging the **Get Lead Activities** endpoint, you can effectively gather email marketing insights data from Marketo. This data can be further analyzed and processed to gain valuable insights into email performance and improve marketing strategies.