Hello Marketo Engage community,
Here are the steps for writing a custom activity into a lead record in Marketo. I pieced together the documentation with the open source github library to get people started.
Prerequisites include you have downloaded Python 3 and above, you have an environment setup to write calls using your IDE of choice.
Resources for reference:
Marketo rest endpoint documentation:
Marketo-rest-python open source library: https://github.com/jepcastelein/marketo-rest-python (Jep Castelein thank you)
Let's us begin,
First create the custom activity in your instance within the admin section.
create your fields attached to the custom activity:
perfect, now we have what we need in Marketo to write the activity to the lead record.
Now lets write some code:
The key values:
Lead id: (Lead id of the record you want to write the custom activity to)
ActivityDate: (2023-09-07T09:51:00-08:00) Must be in this format
name: Order placed
PrimaryAttributeValue: "Confirmed Order"
PrimaryAttribute: [apiName: confirmedOrder, name: Confirmed Order, description: order placed]
from marketorestpython.client import MarketoClient
from dotenv import load_dotenv
#I use dotenv it is the most secure way to write calls into Marketo using python
mc = MarketoClient(os.getenv('munchkin_id'),
custom_activities = [
"name": "Order Placed",
"primaryAttributeValue": "Confirmed Order",
"name": "Confirmed Order",
"description": "Order placed"
result = mc.execute(method='add_custom_activities', input=custom_activities)
except Exception as err:
if __name__ == "__main__":
If you followed all of these instructions and filled in your values to your Marketo instance, you should have been able to write the custom activity into your instance by the lead id you chose.
It should look something like this:
Thank you all, have a great day.
Marketo Enthusiast at TA Digital
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.