Skip to main content
Solved

Track add to wishlist events?

  • December 10, 2024
  • 3 replies
  • 47 views

Forum|alt.badge.img+3

Hi we have a wishlist, I was wondering if there is a way to track an “added to wishlist” event and therefore email people accordingly. We use woocommerce. 

 

 

Thank you 

 

 

Best answer by Christiannoerbjerg

Hi ​@armedandgorgeous!

Thank you for posting in the Community!

Let’s go over a possible solution, that might work :-)

Step 1: Confirm Your Wishlist Plugin or Feature:

Identify the wishlist solution you're using with WooCommerce. Common plugins include:

  • YITH WooCommerce Wishlist
  • TI WooCommerce Wishlist
  • A custom-built wishlist feature

Most plugins trigger actions (such as adding an item to a wishlist) that you can hook into with WordPress/WooCommerce.

Step 2: Send Wishlist Events to Klaviyo:

You can use Klaviyo’s Track API to send a custom "Added to Wishlist" event whenever a customer adds an item to their wishlist.

Example Code to Send Event:

Add this PHP code to your WooCommerce site's child theme's functions.php file or a custom plugin:

function klaviyo_track_wishlist_event($product_id) { // Get product details $product = wc_get_product($product_id); $product_name = $product->get_name(); $product_url = $product->get_permalink(); $product_image = wp_get_attachment_url($product->get_image_id()); // Get the user's email (requires they are logged in or capture it another way) $user = wp_get_current_user(); $user_email = $user->user_email; // Prepare Klaviyo API payload $payload = array( "token" => "YOUR_PUBLIC_API_KEY", // Replace with your Klaviyo public API key "event" => "Added to Wishlist", "customer_properties" => array( "$email" => $user_email ), "properties" => array( "Product Name" => $product_name, "Product URL" => $product_url, "Product Image" => $product_image ), "time" => time() ); // Send the event to Klaviyo $response = wp_remote_post("https://a.klaviyo.com/api/track", array( 'method' => 'POST', 'headers' => array( 'Content-Type' => 'application/json' ), 'body' => json_encode($payload) )); } // Hook into your wishlist plugin's "add to wishlist" action add_action('yith_wcwl_added_to_wishlist', 'klaviyo_track_wishlist_event', 10, 1);

What this does:

  • Hooks into your wishlist plugin's action (yith_wcwl_added_to_wishlist) to trigger the event whenever a product is added to the wishlist.
  • Sends the event to Klaviyo’s API with relevant product details (name, URL, image) and the user’s email.

For other wishlist plugins:

  • Replace yith_wcwl_added_to_wishlist with the action provided by your specific plugin.
  • Check your plugin documentation for the correct hook to use.

Step 3: Verify the Event in Klaviyo:

  1. Go to Analytics > Metrics in Klaviyo.
  2. Look for a new metric called "Added to Wishlist".
  3. Check the event data to ensure it includes the expected details (email, product name, URL, etc.).

Step 4: Create a Flow to Target Wishlist Users:

Once the event is being tracked in Klaviyo, you can build a flow to email users who add items to their wishlist.

Steps to Create the Flow:

  1. Go to Flows in Klaviyo and click Create Flow.
  2. Select Create from Scratch.
  3. Set the flow trigger as Metric-Triggered Flow.
  4. Choose "Added to Wishlist" as the trigger.

Hope that helps! :-) 

Christian Nørbjerg Enger
Partner & CPO
Web: Segmento.dk
LinkedIn: @christianfromsegmento
Voldbjergvej 22b, 8240 Risskov

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

Forum|alt.badge.img+7
  • Klaviyo Employee
  • 168 replies
  • December 10, 2024

If you added a custom form to the product page, you could use the JavaScript track call to send an event to the profile, with the product ID as an event property.

https://developers.klaviyo.com/en/docs/javascript_api#track-events-and-actions


retention
Partner - Platinum
Forum|alt.badge.img+62
  • 2025 Champion
  • 920 replies
  • December 10, 2024

Hi ​@armedandgorgeous, if your wishlist tool doesn’t integrate with Klaviyo directly, then ​@saulblum method allows you to create your own custom events in Klaviyo.  For newcomers to custom events, I find this little academy quick guide on Klaviyo handy: 


Christiannoerbjerg
Expert Problem Solver II
Forum|alt.badge.img+12

Hi ​@armedandgorgeous!

Thank you for posting in the Community!

Let’s go over a possible solution, that might work :-)

Step 1: Confirm Your Wishlist Plugin or Feature:

Identify the wishlist solution you're using with WooCommerce. Common plugins include:

  • YITH WooCommerce Wishlist
  • TI WooCommerce Wishlist
  • A custom-built wishlist feature

Most plugins trigger actions (such as adding an item to a wishlist) that you can hook into with WordPress/WooCommerce.

Step 2: Send Wishlist Events to Klaviyo:

You can use Klaviyo’s Track API to send a custom "Added to Wishlist" event whenever a customer adds an item to their wishlist.

Example Code to Send Event:

Add this PHP code to your WooCommerce site's child theme's functions.php file or a custom plugin:

function klaviyo_track_wishlist_event($product_id) { // Get product details $product = wc_get_product($product_id); $product_name = $product->get_name(); $product_url = $product->get_permalink(); $product_image = wp_get_attachment_url($product->get_image_id()); // Get the user's email (requires they are logged in or capture it another way) $user = wp_get_current_user(); $user_email = $user->user_email; // Prepare Klaviyo API payload $payload = array( "token" => "YOUR_PUBLIC_API_KEY", // Replace with your Klaviyo public API key "event" => "Added to Wishlist", "customer_properties" => array( "$email" => $user_email ), "properties" => array( "Product Name" => $product_name, "Product URL" => $product_url, "Product Image" => $product_image ), "time" => time() ); // Send the event to Klaviyo $response = wp_remote_post("https://a.klaviyo.com/api/track", array( 'method' => 'POST', 'headers' => array( 'Content-Type' => 'application/json' ), 'body' => json_encode($payload) )); } // Hook into your wishlist plugin's "add to wishlist" action add_action('yith_wcwl_added_to_wishlist', 'klaviyo_track_wishlist_event', 10, 1);

What this does:

  • Hooks into your wishlist plugin's action (yith_wcwl_added_to_wishlist) to trigger the event whenever a product is added to the wishlist.
  • Sends the event to Klaviyo’s API with relevant product details (name, URL, image) and the user’s email.

For other wishlist plugins:

  • Replace yith_wcwl_added_to_wishlist with the action provided by your specific plugin.
  • Check your plugin documentation for the correct hook to use.

Step 3: Verify the Event in Klaviyo:

  1. Go to Analytics > Metrics in Klaviyo.
  2. Look for a new metric called "Added to Wishlist".
  3. Check the event data to ensure it includes the expected details (email, product name, URL, etc.).

Step 4: Create a Flow to Target Wishlist Users:

Once the event is being tracked in Klaviyo, you can build a flow to email users who add items to their wishlist.

Steps to Create the Flow:

  1. Go to Flows in Klaviyo and click Create Flow.
  2. Select Create from Scratch.
  3. Set the flow trigger as Metric-Triggered Flow.
  4. Choose "Added to Wishlist" as the trigger.

Hope that helps! :-) 

Christian Nørbjerg Enger
Partner & CPO
Web: Segmento.dk
LinkedIn: @christianfromsegmento
Voldbjergvej 22b, 8240 Risskov