SOLVED

Get Lead Activities API

Go to solution
wbarnes0113
Level 2

Get Lead Activities API

I'm utilizing the Get Lead Activies access point and am receiving variations of the data versus the Marketo UI views. Below is some of my code - I am incrementing by 15 days at a time in case the data size is an issue.

act = mc.execute(method='get_lead_activities',
                                activityTypeIds=['3', '6', '7', '8', '9', '10', '11', '27'],
                                sinceDatetime='2022-12-01',
                                untilDatetime='2022-12-15')

 

It had been working just fine until my organization wanted me to backdate more data with more columns. Backdating it has caused these issues to come up.

If there is a will, there is a way.
Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Get Lead Activities API

Please use the syntax highlighter when posting code (I edited your post both times).

 

This isn’t, of course, JSON as requested. But you did specify that you’re calling the paginated Get Lead Activities endpoint, which is helpful.

 

Get Lead Activities fetches pages of results starting from a specific start time. You can stop fetching at any time, thus the question about size concerns. Just because your start time is 2020-01-01T00:00:00Z, that doesn’t mean you’re fated to get all data since then. It’s only fetching <= 300 results at a time and you can abort whenever. It’s not a single connection with a giant response.

 

The disparity between results is almost certainly because:

 

(a) Marketo aggregates results in canned analytics/reports and doesn’t recalculate if people have since been purged

(b) activity logs age out — high-volume activities like Delivered after just 90 days

(c) Marketo “upgrades” aggregate figures for Opens to include people who clicked emails but did not register a literal Opened Email activity (i.e. tracking pixel download)

 

These are all long-established Marketo behaviors.

 

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Get Lead Activities API

Your question is far from clear: you’re not showing what API endpoint you’re calling, nor what JSON payload is actually going on the wire. So we really have no idea what this code does — or thinks it does!

 

Nor do we know what “variations” you‘re seeing since you haven’t provided any examples.

 

So please rephrase your question in terms of the actual code put on the wire (not in a programming language, in JSON), where you’re sending it, what you’re seeing in the response, and what specifically is surprising about it.

 

P.S. Also explain the “data size” concern, since a paginated API endpoint doesn’t have a capped data size.

wbarnes0113
Level 2

Re: Get Lead Activities API

Thank you for your response.

 

Essentially - I am attempting to retrieve activity data from Marketo (hence the activity type ids). I am backdating this data back to 2022 and essentially the problem is the Delivered #, Open #,  Link opens on the back-end (once the API data syncs to the SQL database) does not match anywhere near the Marketo front-end and I have no reason why it could be operating that way.

 

I am utilizing the marketorestpython module in Python and am attempting to retrieve activity data - so that is essentially all I am calling. Requesting activity data from the API with those specific activity type ids and within that start and end date range.

 

I had this working just find but my organization wanted to add in the marketoguid and primaryattributevalueid fields (hence why I had to back-date it). Prior to this, it was all calculating correctly.

 

Here again is the code utilized to request the data (with more lines and background)-

munchkin_id = parm_key(connection, 'marketo_munchkin_id')
client_id = parm_key(connection, 'marketo_client_id')
client_secret = parm_key(connection, 'marketo_client_secret')

args = {'grant_type': 'client_credentials',
'client_id': client_id,
'client_secret': client_secret}
host = 'https://{' + munchkin_id + '}.mktorest.com'

api_limit=None
max_retry_time=None

mc = MarketoClient(munchkin_id, client_id, client_secret, api_limit, max_retry_time)

act = mc.execute(method='get_lead_activities',
activityTypeIds=['3', '6', '7', '8', '9', '10', '11', '27'],
sinceDatetime=start_date,
untilDatetime=end_date)

-------------------------------------------------------------------------------------------------

 

here is a link to the marketo equivalent (outside of the module) - https://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#/Activi...

 

here is a link to the module I utilize - https://github.com/jepcastelein/marketo-rest-python

 

 

If there is a will, there is a way.
SanfordWhiteman
Level 10 - Community Moderator

Re: Get Lead Activities API

Please use the syntax highlighter when posting code (I edited your post both times).

 

This isn’t, of course, JSON as requested. But you did specify that you’re calling the paginated Get Lead Activities endpoint, which is helpful.

 

Get Lead Activities fetches pages of results starting from a specific start time. You can stop fetching at any time, thus the question about size concerns. Just because your start time is 2020-01-01T00:00:00Z, that doesn’t mean you’re fated to get all data since then. It’s only fetching <= 300 results at a time and you can abort whenever. It’s not a single connection with a giant response.

 

The disparity between results is almost certainly because:

 

(a) Marketo aggregates results in canned analytics/reports and doesn’t recalculate if people have since been purged

(b) activity logs age out — high-volume activities like Delivered after just 90 days

(c) Marketo “upgrades” aggregate figures for Opens to include people who clicked emails but did not register a literal Opened Email activity (i.e. tracking pixel download)

 

These are all long-established Marketo behaviors.