How to search WooCommerce user meta data

In today’s article, we are going to show you how you can search the WooCommerce custom user fields. WooCommerce saves a lot of information about your users as user meta, but usually, we can’t easily search through this data. Therefore we’ll use the Users Insights plugin to better understand the WooCommerce data and how to get WooCommerce user meta and the users assigned to these custom fields.

Beyond that, our goal today is getting a good understanding of what kind of user meta WooCommerce has. We’ll also perform different user searches and filters, and we’ll see how you can use this information in your WooCommerce store.

The main topics of our discussion are:

  • What is user meta and what kind of data WooCommerce stores
  • Loading user meta in Users Insights
  • Searching WooCommerce user meta
  • Searching the default WooCommerce fields

Let’s get started!

woocommerce user meta search

What is user meta and what kind of data WooCommerce stores

User meta are custom fields used by plugins and themes to store information about your users. All the information you see in a WooCommerce store has to be stored somehow, and the custom user fields are the best way to store user related data.

Therefore, information such as social media address, billing and shipping details, occupation and others are all stored via user meta. These custom fields can be accessed not just by the plugin that created them. So, if WooCommerce stores the shipping address for a user, all other plugins can access that.

There’s a wide range of fields at your disposal when you have some WooCommerce users and orders. We’ll focus on the more straightforward and reliable data such as billing and shipping address. You can also create your own custom fields on WooCommerce user registration. We’ll mention how you can use fields added by this method, such as collecting the job title or a newsletter opt-in.

There are other fields such as the lifetime value that isn’t as accurate as we’d like. For this reason, we’ll use the Users Insights WooCommerce Lifetime value instead. This field has the same purpose of the default lifetime value but has a much more precise method.

You can also load other referenced data, as the orders themselves. We’ll need a bit of custom code to format these fields in a way that we can use them. Nonetheless, it’s a very interesting method of loading user meta, as it allows complex data loading.

 

Loading user meta in Users Insights

The Users Insights plugin has a WooCommerce module. It allows a wide array of fields such as number of orders and lifetime value, to be loaded as soon as you enable it:

However, you may want to load other fields as well. You can easily load fields that are stored as user meta just by using the Custom Fields feature and map your fields. You can do that under Users Insights > Custom fields. In this way we can load the WooCommerce user meta fields such as shipping country and billing country.

Additionally, if you have other custom fields stored for your users (like checkout form fields or fields stored by other plugins), we can load their data as well. In this example, we are going to load the job title and newsletter registration custom fields that we request in our checkout form.

Mapping custom user fields for later use

Now it’s time to perform some WooCommerce users custom meta search using all of the fields that we have available.

 

Searching WooCommerce user meta

Once you know a little bit your customer base, you may get a feel for where your users are from. But how accurate is your feeling? Let’s put that to test by searching WooCommerce using custom fields for billing and shipping countries.

You can just check how many users from a certain country you’ve got, based on their shipping address:

All customers from United States

You can compare that with other countries, or if you have a lot of orders from one country you can check which users aren’t from it. This is going to give you an idea of how the other countries are performing.

You can also compare the shipping address results with the billing address. You may be surprised to find out that often WooCommerce customers buy from one country and want the goods to be delivered elsewhere:

Customers with different billing and shipping countries

In our case, we have X orders that were made in the US, but were delivered to another country.

You can also get WooCommerce user meta and use it to get a better feel of your audience. Since we’ve mapped the job title and newsletter opt-in fields we can use them for that.

You may want to check how many developers from your customer base are also in your newsletter:

Developers who are subscribed to the newsletter

Based on that you can perform other WooCommerce user meta searches. You can use different job titles or check the ones who are not in the newsletter. You can also combine the custom search with the default fields, such as getting all developers who have the billing address as US:

Developers who are from outsite the United States

 

Searching the default WooCommerce fields

Now that we saw how you can search WooCommerce users using custom fields, let’s see how to do the same with the default fields. In this case, we’ll focus on the data available when you enable the WooCommerce module in Users Insights, regarding orders and lifetime value.

Let’s get a feel of our most recent customers by searching for users who have purchased in the last 90 days.

Most recent active WooCommerce customers

Now it’s time to improve this search. Let’s find all the repeat buyers in that period, by filtering only users who made more than 1 order:

Recent customers who are also repeat buyers

Don’t forget that you can export these users. So, after you’ve found some useful information about your users you can click the export button and use the CSV file in an external software.

 

Conclusion

Today we looked into different methods of performing WooCommerce user meta searches. We also discussed the most basic concepts of custom user meta, how they can be used and how you can add your own data.

By the end of the day, you should be able to map your WooCommerce user custom fields and search any data you want in your site.

We hope you enjoyed this article, and see you again next time!