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:	ecommercehints.com

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

WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers