Awareness is the very first stage in any sales funnel. The user has to be aware of your existence before they can purchase through your site. This guide shows you how you can capture how a user became aware of your store, allowing you to focus your marketing in the necessary areas. This guide shows you how to add a radio button form to the thank you page, show a thank you message, and show the feedback from the customer as an order note in the order editor in the WooCommerce Orders dashboard. If you’re feeling up to it, you could tweak this code snippet to ask for feedback on what users thought of your store, or even ask other questions like, would you recommend to a friend, or why did you purchase through us?
/*
* Snippet Name: WooCommerce Thank You Page awareness form
* Snippet Author: ecommercehints.com
*/
add_action( 'woocommerce_thankyou', 'ecommercehints_awareness_feedback_form', 20 );
function ecommercehints_awareness_feedback_form( $order_id ) {
echo 'How Did You Hear About Us?
';
}
add_action( 'wp_footer', 'ecommercehints_thank_you_ajax_message' );
function ecommercehints_thank_you_ajax_message(){
if( !is_wc_endpoint_url( 'order-received' ) ) return;
echo "";
}
add_action( 'wp_ajax_collect_feedback', 'ecommercehints_thank_you_ajax' );
add_action( 'wp_ajax_nopriv_collect_feedback', 'ecommercehints_thank_you_ajax' );
function ecommercehints_thank_you_ajax(){
check_ajax_referer( 'thankyou'.$_POST['order_id'], 'thankyou_nonce' );
if( $order = wc_get_order( $_POST['order_id'] ) ) {
$store_name = get_bloginfo('name');
$note = $order->get_formatted_billing_full_name() . ' heard about ' . $store_name . ' through: ' .$_POST['awareness'] . '.';
$order->add_order_note( $note, 0, true );
}
die();
}