In this short post I’ll show you how to add a customer survey to the Woocommerce thank you page. Setting this up will take only a couple of minutes.
Here’s what the end result will look like for my site.
Video: How to Add a Customer Survey to the Woocommerce Thank You Page?
Here’s a video overview abou all it.
Step 1: Create a survey with Fluent Forms
Although I use Fluent Forms for my site, you can use any other form plugin that allows you to create surveys. Just add your form fields and set everyhting up according to your needs.
If this is done then fin out what is the form shorcode. In my example it’s:
[fluentform id="3"]
Step 2: Add survey to your Woocommerce thank you page
In order to accomplish this just grab this snippet here below add it to your site. If you don’t know where to add the code snippet displayed here below, then add it either to your child theme’s functions.php file or better yet, use a snippet manager like Code Snippets
// Add a Customer Survey on Woocommerce Thank You Page
add_action( 'woocommerce_thankyou', 'wpsh_thankyou_page_survey' );
function wpsh_thankyou_page_survey() {
echo do_shortcode( '' );
}
Pay attention though that if you need to style your survey form a bit then you need to add a class to it. For example, the snippet here below adds “woocommerce-message” class to the form and it results with a gray background. Also, I added some inline styling to it, that is “style=”margin-top: 2em;”
In a similar way you can add your own class to it (for example “survey-form” class). Don’t forget to add a related CSS to the Appearance >> Customize >> Additional CSS.
// Add a Customer Survey on Woocommerce Thank You Page
add_action( 'woocommerce_thankyou', 'wpsh_thankyou_page_survey_styled', 20 );
function wpsh_thankyou_page_survey_styled() {
echo do_shortcode( '<div class="woocommerce-message" style="margin-top: 2em;"></div>' );
}