Skip to content

Commerce Foundations is our pre-built Craft Commerce store. See what it includes

Actions

You can use Klaviyo Connect Plus plugin actions (in forms and links, see Templating Examples) to perform various Klaviyo actions from your Craft templates.

Identify POST /klaviyo-connect-plus/api/identify

This action is used to track properties about an individual without tracking an associated event.

See the Profile Form Parameters in the Update Profile action.

Note: Profiles can be updated provided the email address used is the same as an existing Klaviyo profile.

Warning: Forms that POST to the ‘identify’ and ‘track’ endpoints on unauthenticated pages (Craft user sign-in not required) can be abused to update existing Klaviyo profiles.

Update Profile POST /klaviyo-connect-plus/api/track

This action is used to add a user to a list or multiple lists and/or track events from a user.

Calls the identify API too.

Profile Form Parameters

These apply to both actions.

email or profile[email] Required

An email address to identify a person’s profile on Klaviyo

If profile[email] is not present, email will be used.

<input type="hidden" name="email" value="hi@mysite.com" />
<!-- or -->
<input type="hidden" name="profile[email]" value="hi@mysite.com" />

Custom Event Properties

If you’d like to pass through custom profile properties, add them into the profile array.

profile[PropertyName]

<input type="hidden" name="profile[LastLogin]" value="{{ currentUser.lastLoginDate|date('Y-m-d\TH:i:sP') }}" />

Klaviyo-specific Profile properties

See Klaviyo Notes and Special Identify Properties in Klaviyo’s API docs.

<input type="hidden" name="profile[first_name]" value="{{ currentUser.firstName }}" />
<input type="hidden" name="profile[last_name]" value="{{ currentUser.lastName }}" />

List Parameters

List form parameters can be passed to Klaviyo as either a single list or multiple lists.

Either list or lists[] needs to be present to add a user to a list:

list - Required

Klaviyo list ID.

<input type="hidden" name="list" value="{{ entry.listField.id }}" />

lists[] - Required

Array of Klaviyo List IDs

<select name="lists[]" multiple>
  {% for list in entry.listsField %}
    <option value="{{ list.id }}">{{ list.name }}</option>
  {% endfor %}
</select>

Tracking Event Parameters

If event form parameters are present, Klaviyo’s tracking API will be called to track the event and associate it to the user.

event[name] - Required

The name of the event to track.

<input type="hidden" name="event[name]" value="Completed Order" />

event[unique_id] - Required See Klaviyo Notes

The ID to associate with an event, e.g. Order ID.

<input type="hidden" name="event[unique_id]" value="{{ order.number }}" />

event[value] - Required See Klaviyo Notes

Value associated with an event, e.g. Total Cost.

<input type="hidden" name="event[value]" value="{{ order.totalPrice }}" />

event[value_currency] - Required See Klaviyo Notes

The ISO 4217 currency code of the value associated with the event. e.g. USD.

<input type="hidden" name="event[value_currency]" value="USD" />

Custom Event Properties

If you’d like to pass through custom event properties, add them into the event array.

event[PropertyName] - Optional

Associative arrary of extra properties to be assigned to the event in Klaviyo.

<input type="hidden" name="event[Foo]" value="Bar" />

Extra Form Parameters

The following extra parameters can be used in POST actions.

event[trackOrder] - Optional

When present, will trigger the order tracking logic as apposed to regular event tracking. If event[orderId] is set, that specific order will be used, otherwise the customer’s current cart will be used.

This is useful in situations where the built-in order tracking is not sufficient, for example, tracking partial payments.

<input type="hidden" name="event[name]" value="Partial Payment" />
<input type="hidden" name="event[trackOrder]" value="1" />
<input type="hidden" name="event[orderId]" value="543" />

event[orderId] - Optional

The ID of the order to track. Requires trackOrder to be present.

forward - Optional

Tells the plugin to forward the POST request to a specified action once complete. If the forward form parameter is not included, the POST will follow the Craft Commerce redirect field, if present.

<input type="hidden" name="forward" value="/commerce/cart/update-cart" />

subscribe - Optional

Whether to subscribe a user to a list or add their profile to a list (default). This has the benefit of respecting the double opt-in setting of the list.

<input type="hidden" name="subscribe" value="1" />

Restore Cart GET /klaviyo-connect-plus/cart/restore

Restores a previously active cart. Best used in a Klaviyo generated email to a specific customer.

Parameters

number - Required

The cart number of the cart you wish to restore.

<a href="https://mysite.com/actions/klaviyo-connect-plus/cart/restore?number=10a6a60e178f6d19ad58b2184001217b">Restore your cart</a>

In Klaviyo, if you’ve set up a flow based on the Started Checkout event, for example, you could create an email template to restore users’ carts:

<a href="https://mysite.com/actions/klaviyo-connect-plus/cart/restore?number={{ event.OrderNumber }}">Go to your cart</a>

See Klaviyo’s Template Tags & Syntax documentation.

Think we might be a fit?

Start a conversation
See if we’re a fit