Is it possible to update a contact's actions via the APIs?

Is it possible to update contact.actions via the contact_add or contact_sync apis? I would like to update the contact’s actions as they achieve specific milestones in our application. This information is critical to providing them with the best support and educational marketing.

If it is possible, how would I go about encoding that as Content-Type: application/x-www-form-urlencoded?

Hi there, Amy from ActiveCampaign’s Customer Experience Team. We’re just refreshing our forum page and I wanted to add some help here for anyone who comes across this page/question/post.

Yes, it’s possible to update a contact’s actions in ActiveCampaign using API. However, the contact.actions field cannot be directly updated via the contact_add or contact_sync APIs. The contact.actions field in ActiveCampaign represents the actions the contact has taken within the ActiveCampaign system, such as opening emails, clicking links, etc. It’s not intended to be directly manipulated via API to track custom milestones in your application.

To track custom milestones or events from your application, you can use ActiveCampaign’s Event Tracking API. Here’s how you can do it:

  1. Create an Event: Before you can track an event for a contact, you need to define the event in your ActiveCampaign account. You can do this via the ActiveCampaign dashboard or through the API.
  2. Track the Event for a Contact: Once the event is defined, you can track it for a specific contact using the Event Tracking API. You would typically make a POST request to the /api/3/eventTrack endpoint with the contact’s email and the event details.

As for encoding the request as Content-Type: application/x-www-form-urlencoded, here’s how you can do it using Python’s requests library:

python

Copy code

import requests

url = "https://your-account.api-us1.com/api/3/eventTrack"

payload = {
    "event": "Your Event Name",
    "key": "your-api-key",
    "actid": "your-act-id",
    "eventdata": {
        "email": "contact@example.com",
        "eventKey": "unique-event-key",
        "eventData": "additional-data"
    }
}

response = requests.post(url, data=payload)

print(response.text)

In this example, replace "Your Event Name", "your-api-key", "your-act-id", "contact@example.com", "unique-event-key", and "additional-data" with your actual data.

This will encode the payload as application/x-www-form-urlencoded automatically by the requests library.

Any questions or additional ideas, thread them below!