Thank You Page

WooCommerce Thank You Page How Did You Hear About Us

WooCommerce Thank You Page showing where did you hear about us feedback form which saves to order meta


There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

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:

add_action( 'woocommerce_thankyou', 'ecommercehints_awareness_feedback_form', 20 );

function ecommercehints_awareness_feedback_form( $order_id ) {

 	echo '<h2>How Did You Hear About Us?</h2>
		<form id="awareness_feedback_form">
		<label><input type="radio" name="awareness" value="Google Search"> Google Search</label><br>
		<label><input type="radio" name="awareness" value="Social Media"> Social Media</label><br>
		<label><input type="radio" name="awareness" value="Through a friend"> Through a friend</label>
		<input type="hidden" name="action" value="collect_feedback" />
		<input type="hidden" name="order_id" value="' . $order_id . '" />
		' . wp_nonce_field( 'thankyou'.$order_id, 'thankyou_nonce', true, false ) . '


add_action( 'wp_footer', 'ecommercehints_thank_you_ajax_message' );

function ecommercehints_thank_you_ajax_message(){

	if( !is_wc_endpoint_url( 'order-received' ) ) return;
	echo "<script>
	jQuery( function( $ ) {
		$('input[type=radio][name=awareness]').change(function() {
				url: '" . admin_url('admin-ajax.php') . "',
				type: 'POST',
				data: $('#awareness_feedback_form').serialize(),
				beforeSend : function( xhr ){
					$('#awareness_feedback_form').html('Nice one, thanks for your feedback!');
				success : function( data ){
					console.log( data );


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 );



100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.