To send an event to Klaviyo, we use the "http" action. Your task script might look something like this:

{% assign klaviyo_data = hash %}
{% assign klaviyo_data["token"] = options.klaviyo_api_token__required %}
{% assign klaviyo_data["event"] = options.klaviyo_event__required %}
{% assign klaviyo_data["customer_properties"] = hash %}
{% assign klaviyo_data["customer_properties"]["$email"] = customer.email %}

{% action "http" %}
  {
    "method": "get",
    "url": "https://a.klaviyo.com/api/track?data={{ klaviyo_data | json | base64 }}"
  }
{% endaction %}

To get a clear summary of what data is being sent to Klaviyo, consider logging the klaviyo_data variable:

{"log": {{ klaviyo_data | json }}}

To allow configuring Klaviyo event properties with merchant-configurable task options, add something like this:

{% assign klaviyo_data["properties"] = options.event_properties__keyval | default: hash %}

Or, to configure those properties dynamically, use this:

{% assign klaviyo_data["properties"] = hash %}
{% assign klaviyo_data["properties"]["Some property"] = "Some value" %}
Did this answer your question?