• calebgittins

    (@calebgittins)


    Are there any filters available to send custom order meta to the “extra” item in the payload?

    We would like to send custom meta eg ‘_store_location’ so we can use this for filtering and exclusions within Klaviyo

Viewing 1 replies (of 1 total)
  • Plugin Support brianklaviyo

    (@brianklaviyo)

    Hey Caleb,

    Unfortunately we do not have any filters or way to adjust the order payloads at this time. For any server-side events we normalize the data and these inputs take fixed key:values based on what we’re expecting to ingest on our end.

    It is however possible from a client-side event perspective like with started checkout or added to cart if there’s a potential workaround there. For example:

    These filters are available in the public WooCommerce–Klaviyo plugin and control what ends up under extra / $extra in the payload:

    1. Per line item in extra.Items (Started Checkout)
      • Function wck_build_cart_data() builds the Started Checkout payload and pushes each cart item into:
        $event_data['$extra']['Items'][] = ...
      • Before each item is added, the plugin runs the **kl_checkout_item** filter:$event_data['$extra']['Items'][] = apply_filters( 'kl_checkout_item', $item, $product, $values );php
      • You can use this filter to append custom fields to each line item, e.g. StoreLocation, which will then appear at:
        Started Checkout → extra.Items[].StoreLocation.
    2. Whole Started Checkout payload (including $extra)
      • After wck_build_cart_data() returns, wck_started_checkout_tracking() runs kl_started_checkout on the full $event_data array: $event_data = apply_filters( 'kl_started_checkout', $event_data, $cart );php
      • You can add cart-level data into $event_data['$extra'], e.g.:$event_data['$extra']['StoreLocation'] = 'Boston';php
    3. Added to Cart payload (extra block)
      • kl_build_add_to_cart_data() builds the Added to Cart payload and includes:'extra' => $wck_cart['$extra'],php
      • Before sending, the plugin runs the kl_added_to_cart filter: $added_to_cart = apply_filters( 'kl_added_to_cart', $added_to_cart, $added_product, $quantity, $wck_cart );php
      • You could add something like:$added_to_cart['extra']['StoreLocation'] = 'Boston';php
      That will surface under Added to Cart → extra.StoreLocation in Klaviyo.

    The other alternative would be to run a custom event for Order metrics so you would have full control over the data being sent but that also requires the means and infrastructure to do so (and obviously not something exclusive to the integration/plugin). I’d be happy to put in a feature request on your behalf for the custom meta data on Order events being potentially customizable or at least to include a an object that allows for some flexibility for customizations in the future.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.