Question

Resolving Execution Order Issue with CustomerIo Events and Campaigns

  • 10 November 2023
  • 1 reply
  • 37 views

I'm working with an API that interacts with CustomerIo. My code is structured to send user attributes to CustomerIo and, upon receiving a successful response, it makes an additional call to CustomerIo with an 'attributes_updated' event. The code looks like this:

    result = CustomerIoApiGateway.send_user(user_attributes, {'id' => @user.id})
if result.success?
result = CustomerIoApiGateway.send_event(@user, 'attributes_updated', user_attributes)
end

On the CustomerIo side, I have a campaign triggered by the attributes_updated event. This campaign calculates new attribute values such as crm_usage_setup based on the attributes I've sent (such as team_clients_count ) ​​​​​​


 

 

However, I'm facing an issue with the order of execution on CustomerIo’s side. Sometimes, the sequence of operations is not as expected, leading to scenarios where CustomerIo:

  1. Registers the 'attributes_updated' event.
  2. Executes the campaign, updating the crm_usage_setup value based on old `team_clients_count` attribute value.
  3. Updates the attributes (team_clients_count) to the new ones.

This issue leads to incorrect calculations for the crm_usage_setup because the Campaign is beign triggered by attributes_updated  event and executed, before Customer.io updates team_client_count  attribute itself (which i have sent to CIO, before attributes_updated event )

I would greatly appreciate any suggestions or ideas on how to resolve this issue to ensure the correct order of execution. Thank you in advance!

 


1 reply

Userlevel 2

Hi there,

Thanks for reaching out!

It sounds like you’re experiencing a race condition where the initial attribute update hasn’t been completely processed by the time the event-triggered campaign is processed. This can happen when different processes are happening at around the same time.

What we recommend in these cases, is to add a small delay of a minute before your attribute update action in your workflow. This will give the initial attribute update enough time to process before the move into the workflow action to update “crm_usage_setup”.

I hope this helps, but let us know how it works out!

Ryan

 

Reply