/** * Track custom events in Mixpanel * * Placeholders: * * `hook_to_trigger_event_on`: replace with the hook you would like this event to trigger on; eg: `woocommerce_add_to_cart` * * `Event Name`: replace with custom even name * * $properties array: replace with an array of custom property names and values in the `'Property Name' => 'Property Value'` format */ function sv_wc_mixpanel_track_custom_event() { if (!function_exists('wc_mixpanel')) { return; } $properties = array('Property Name' => 'Property Value'); wc_mixpanel()->get_integration()->custom_event('Event name', $properties); }
/** * Track custom user properties via the Mixpanel API * * This example illustrates how to add/update the "Last Subscription Billing Amount" * user property when a subscription is renewed. * * @param \WC_Order $renewal_order * @param \WC_Order $original_order * @param int $product_id the * @param \WC_Order $new_order_role */ function sv_wc_mixpanel_renewed_subscription($renewal_order, $original_order, $product_id, $new_order_role) { if (!function_exists('wc_mixpanel')) { return; } $properties = array('Last Subscription Billing Amount' => $renewal_order->get_total()); wc_mixpanel()->get_integration()->custom_user_properties_api($properties, $renewal_order->user_id); }