[API] How to obtain the email analytics data efficiently

HZ23
Level 1

[API] How to obtain the email analytics data efficiently

Hi,

Is there a quick and easy way of getting the total numbers of email sent, delivered, open, click etc data ?

I have the email ids as well as their program and folder id that I wanna pull the data for but I cannot find any endpoint where I can pull the analytics data by the email id.

 

This is how I am doing it now. I am creating the bulk extract jobs [https://developers.marketo.com/rest-api/bulk-extract/]  With the following body:

 

{
    "format": "CSV",
    "filter": {
        "createdAt": {
            "startAt": "2019-07-02T00:00:00-00:00",
            "endAt": "2019-07-04T23:59:59-00:00"
        },
        "activityTypeIds": [
            6,
            7,
            9,
            10,
            11,
            27,
            39,
            40,
            41,
            45
        ]
    },
    "fields": [
        "activityDate",
        "activityTypeId",
        "primaryAttributeValueId"
    ]
}

The activity type ids are the ids of the email-related activities, such as open, click, delivered etc.

The issue is that this takes a long time to run, I have to go through the different timelines and filter through the activity data for the emails that I am not interested in.

 

I am looking for a way where I can pass the email id and get all the data associated with only the emails I specified.

 

Any help is appreciated.

Thanks.

 

Tags (1)
2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: [API] How to obtain the email analytics data efficiently

Unfortunately you can’t prefilter the response by asset ID for all those Activity Types. You have to filter on the client side. (But really you should always be prepared for this outcome as the Bulk Extract is designed to pull the raw data which is then imported into some of kind of easily-queried/rotated db.)

You could switch to the paginated Bulk Export instead, which filters by asset, but I don’t know if that would be net-net easier for you.
Jo_Pitts1
Level 10 - Community Advisor

Re: [API] How to obtain the email analytics data efficiently

@HZ23 ,

I was intrigued by this statement:


The issue is that this takes a long time to run, I have to go through the different timelines and filter through the activity data for the emails that I am not interested in.

 

This might sound odd, but maybe life would be easier if you pulled MORE information, and stored it in a nice SQL database

 

If you used the API to pull a list of emails in your system, and then put both activity data and email data into a database, your querying would be very simple, very fast, and you can do it based on email name, not on IDs.  It'd also make it easy to get the analytics across any time frame you want.

 

Cheers

Jo