The Segment documentation does a very good job of getting you up and started with setting up Marketo as a destination. Build on top of this Segment Marketo integration by adding Custom Activities and Fields so that you can get events and lead field values into Marketo.
In particular, this post will help clear up some prickly points like “What is a primary key in a custom activity?” and “Can custom activity fields populate lead fields?”.
In case you missed my first three posts on this topic or need a quick refresher before diving in below then take a cheeky glance at these posts:
Segment Marketo Integration Overview Video
Integrating Segment Events with Marketo Activities
Choosing a Primary Key
Before diving into how to map your Segment event to a Marketo activity I want to explain what the primary key is. When you create a custom activity in Marketo you have to specify a field called the primary field which must be of the string data type and must always be present when the activity is being sent to Marketo.
Therefore when choosing the Segment event property to be the primary key make sure that it matches these two criteria:
- It is of the string data type
- It is always present in the Segment event properties
All the properties for a Segment event can be found by searching for the event in the “Schema” section of the source responsible for sending this event to Segment. Once you have found the event and clicked on it you will see all the properties present in its payload. For more info check out the Segment Source Schema of the “Segment CDP Walkthrough” post.
If you want to find out how to transfer Segment event properties to Marketo person fields then check out the Marketo Trigger Tokens with Custom Activities section.
Integrating a Segment Event with a Marketo Activity
Once the Custom Activity has been created in Marketo then follow the steps below to map a Segment event to this custom activity.
- Navigate to “Connections” > “Destinations”
- Click on your Marketo destination
- Click on “Marketo Custom Activities”
- Click on “Add Another Event”
- If you already have existing custom activities then you will have to scroll past these to see this button
- Fill out the “Segment Event Name”
- Paste in the “Marketo Activity ID”
- Fill out the “Segment Property Name” that you want to map to the primary field you designated in Marketo
- Fill out the “Marketo Field Name” using the API name of the primary field
- Select the “Marketo Field Type”
- For the primary key, this will have to be “string, email, or phone”
- Select the “Set as Primary Key”
- Select “Add Another segmentProperty” and repeat steps 7-9 for every additional Segment event property you want to map to a Marketo activity field
- Click “Save”
- If you already have existing custom activities then you will have to scroll up past these to see this button
Testing the Segment Marketo Integration
Once you have tested that the Marketo activity is set up correctly (see the Marketo Custom Activities Quick Start for how to do this using Postman) then you can use the “Event Tester” in Segment to send a test event to Marketo (see the Segment CDP Walkthrough for how to use the “Event Tester”).
The “Event Lifecycle” in the “Event Tester” will show whether the Segment event was sent correctly to Marketo and it will highlight any issues that may occur. If the test was successful then you should be able to see this Segment event as the Marketo activity within the person’s activity log in Marketo.
Once your custom activity has been set up for a while you can compare the counts of the custom activity arriving in Marketo with the counts of the corresponding event arriving in Segment.
To get the counts of the event arriving into Segment:
- Go to the Schema for the source responsible for sending this event to Segment
- Select either a 7 or 30 day time frame using the dropdown
- Search for the event using the search box
- Note the “Allowed” number for this event over the timespan. It is this value that will be compared with the number of occurrences of the custom activity in Marketo
To get the counts of the custom activity arriving in Marketo follow the steps in the YouTube video above and the Marketo Bulk API Quick-Start Guide:
- Make the “Get Activity Type” API request
- Search for the custom activity name
- Get the id for this custom activity
- Use the bulk extract API to create a job by putting the activity id in the “activityTypeIds” field and setting the “startAt” and “endAt” timestamps to match the timespan you selected in the Segment schema above. Note that you must use UTC time when making this request.
- Enqueue the job using the “exportId” from the previous step
- Get the job data using the “exportId”
The number of rows in the datafile is the number you will compare to the number you got from the Segment schema. If the numbers do not match then check out the “Marketo Delivery Issues” section below to see if there are any issues that can be rectified. Note based on my experience it will be very difficult to get the counts to match up exactly so I’d recommend being happy if they are close enough.
If making the API requests in the YouTube video linked above was confusing then I recommend checking out the Marketo API Crash Course. In particular lesson 5 “An Introduction to the Marketo Bulk Extract API” will walk you through making the API requests mentioned in this blog post using Postman.
Integrating Segment Identify Fields with Marketo Fields
The “Marketo Custom Fields” section is used for mapping the traits in Segment “Identify” events to Marketo fields. Every time you add new traits to the Identify payload being sent from the backend or frontend to Segment make sure that you complete this mapping or else the Marketo field will not be updated when the Identify event gets sent to Marketo.
All that is required to complete the mapping is to include the “Segment Trait Name”, the “Marketo Field Name” (the API name of the field), and the “Marketo Field Type”. Once this is done successfully for each field, a lead in Marketo will either be created or updated with these values from Segment every time an Identify event is sent to Marketo.
Once again you can use the Event Tester to test that you have added the new custom field to the Marketo destination correctly.
Marketo Delivery Issues
The Event Delivery section in your Marketo destination will show any delivery issues that are occurring for your Segment Marketo integration.
A lot of the errors you will see are out of your control. They are due to Segment not adhering to Marketo’s REST API limits and protocols e.g. the 6XX errors below, or system issues between Segment and Marketo e.g. the non 6xx errors below. All of the errors below are usually temporary meaning when Segment later retries sending the event it should go through successfully.
- 601: Access Token Invalid
- 602: Access Token Expired
- 606: Max rate limit of 100 requests per 20 secs exceeded
- 615: Max concurrency rate of 10 concurrent calls exceeded
- Etimedout
- 502 Bad Gateway
- Econnreset
Instead, focus on error codes that you do have the power to fix e.g. 1XXX or “Message Rejected”. The “Message Rejected” error for example occurs because there is an event being sent to Marketo that has not been mapped to a custom activity or does not include all of the required properties e.g. the primary key (see the “Integrating Segment Events with Marketo Activities” section above).
You can use the Event Tester to test out potential fixes and see if the event goes through to Marketo successfully.
What’s After Integrating Segment & Marketo?
Young padawan your journey has just begun!
As Yoda so famously said, “If APIs and Integrations you like, read more Workflow Pro you must!”
- Marketo API Quick-Start Guide
- Integrating Dropbox, Marketo, Rebrandly, and Airtable APIs with Zapier
- Bulk Merging Marketo Duplicates
Marketo Segment Integration FAQs
What is the primary key on a Marketo activity in Segment?
The Segment event property selected as the primary key will map to the primary field on the activity in Marketo. This event property must always be present in the Segment event properties and be of the string data type.
Can I populate lead fields with custom activity field values from Segment?
Yes, it is possible to use trigger tokens in Marketo to transfer the values from Segment event properties to Marketo fields. Check out the Marketo Trigger Tokens with Custom Activities section to see how to use trigger tokens to do this.