Are you seeking a simple and effective way to track feedback from logged in users on your WordPress website? Userback's JavaScript API can help you achieve that.
By identifying users and capturing their information along with their feedback, you can gain valuable insights into your user base. In this guide, we'll show you how to use User Identification with the JavaScript API to identify logged in WordPress users.
The JavaScript API is only available on certain plans. If you're unsure if you have access to this feature, check out this article or chat with Userback support team for more information.
1. Install the Userback WordPress Plugin
Before we delve into identifying logged in users with Userback's JavaScript API, you need to install the Userback WordPress plugin. If you don't have it installed yet, you can download and activate it from the WordPress plugin repository.
2. Add this code to your WordPress theme file
Next, add the following code snippet to your WordPress theme file (typically footer.php), whilst it is recommended, we implore you to find a location that suits your needs.
This code dynamically outputs user information (only if a user is logged in) which is then captured by the Userback Widget and included it with their submitted feedback.
<?php if ( is_user_logged_in() ) { ?>
<script>
<?php $current_user = wp_get_current_user(); ?>
Userback.user_data = {
id: <?php echo ''.$current_user->ID;?>,
info: {
username: '<?php echo ''.$current_user->user_login;?>',
email: '<?php echo ''.$current_user->user_email;?>',
name: '<?php echo ''.$current_user->user_firstname;?> <?php echo ''.$current_user->user_lastname;?>',
display_name: '<?php echo ''.$current_user->display_name;?>',
}
};
</script>
<?php } ?>
3. Test the code and track user feedback
Now that the code has been added to your theme file, it's time to test it out.
Log in to your WordPress site and submit feedback through the Userback widget. You should see the user's information displayed alongside their feedback in your Userback project dashboard. With this information at your fingertips, you'll be able to better understand your users' needs and improve your website or web application accordingly.
π Who is this article for?
Plans | Solo | Startup | Company β | Premium β |