Hi all,
Is it possible to retrieve event data from the ActiveCampaign API after it has been logged to a contact using the “Track event” endpoint?
Not looking for just the event names, which is what the “List all events (names only)” call seems to pull, but rather the actual instances of each event tracked (e.g. event name, event date, associated contact, event data)
2 Likes
I second this question/api feature request.
Jacob, to my knowledge there is no easy way to get this in AC. I’ve been down this rabbit hole several times. The one option I really want to get into but haven’t had the time is using the webhook functionality (trigger a webhook every time a contact does some event). The only issue (aside from all the overhead required to leverage webhooks) is you might have to build an automation for every event you want to capture contact activity for. Without using webhooks, you could create tags but I’m not sure how “dynamic” that option would be (i.e. get a timestamp associated with the tag every time a contact does some event).
Thanks @relevantradio1, I have also been down the rabbit hole so glad to know to know I’m not alone.
I like the idea of webhooks as a backup, although like you said, seems like a lot of work (and no historical data).
Well then I’ve got just the endpoint for you!
For these examples, we’ll use a contact with the id
of 112
:
- To get just the events for a contact, GET:
https://{{yourAccount}}.api-us1.com/api/3/contacts/112/trackingLogs
This will give you events, listed like this:
{
"trackingLogs": [
{
"subscriberid": "112",
"type": "Another event",
"value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure do",
"tstamp": "2022-09-27T12:39:59-05:00",
"hash": "358a9a13d85efb3232414ec57790efb6c13ab3a",
"links": {
"contact": "https://{{yourAccount}}.api-us1.com/api/3/trackingLogs/12/contact"
},
"id": "12",
"contact": "112"
},
{
"subscriberid": "112",
"type": "Yet Another Event",
"value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure do",
"tstamp": "2022-09-27T13:35:01-05:00",
"hash": "abc4307d06ff83df532432e86552dfada77277d",
"links": {
"contact": "https://{{yourAccount}}.api-us1.com/api/3/trackingLogs/15/contact"
},
"id": "15",
"contact": "112"
}
]
}
(Notice that each EVENT has an id (12
and 15
in the above example) and the CONTACT id of 112
)
-
For retrieving events and activities for contact, make a GET: https://{{yourAccount}}/api/3/activities?contact=112
You will find the event listed in both the trackingLogs
object and the activities
object.
This will return a LARGE json object that will contain the events in two different places (trackingLogs
object and the activities
object), and will contain the data you need.
-
To retrieve a contact by EVENT ID, GET: https://{{yourAccountName}}.api-us1.com/api/3/trackingLogs/{{event id}}/contact
(Using the event id mentioned above)
EDIT: These endpoints are now available in the ActiveCampaign DevRel POSTMAN COLLECTION under “Site & Event Tracking”
EDIT2: These endpoints are now in the ActiveCampaign Documentation
1 Like
Ah I see, I think this is what I’ve been looking for, thank you so much for your detailed reply!
1 Like