Lesson info

In this video we provide a short guide on how to install user.com by JavaScript.

Lesson transcript

Let’s find out how to correctly install user.com by custom JavaScript. To enable user.com to track behaviour and actions of your customers and collect data about them, you simply need to add a few lines of code to your website source. To see more information about installing the app by JavaScript, from your app go to Settings and “Setup & integrations”. Important note: “installing user.com” at the same time means “installing chat widget” at your website. By default chat widget will be active upon installation but you can easily hide it. We see here 2 versions of code snippets - for non logged in users and for logged in users.. Very important thing to note: these 2 code snippets are in fact the same code type and you definitely shouldn’t paste them both to your website code. The second version of code is basically the version above expanded by those lines. If you don’t need to pass any user attributes to user.com or you simply don’t store any user attributes in your internal system, use the short version of the code. If your users log in to your app and you’re able to pass their attributes to user.com, expand the code snippet by user attributes you want to pass for logged in users. The first snippet version at the top is to be used to track users that are not logged in at your website. In other words, it assigns a cookie to a user at first visit at your website and so tracks them and passes information pieces about their behaviour to the user.com app. All you need to do is copying that code and pasting it to your website code, just above the closing tag of the “” part. Right below you see the second code snippet version, which passes information to user.com basing on unique user identifier, like user ID. It is used if you want to track users that are logged in at your website. What does it mean exactly? Thanks to this extended version of code snippet the user.com app will receive additional attributes of users logged in at your website, provided that you have already collected some data pieces about them. For example, if shopping at your ecommerce site requires creating a user account, your system collects additional information about users, like for example their first and last names, email address or birthday and so on. If you are a SaaS company, you may for example want to pass information about a user’s current plan or billing status assigned to their subscription. To pass these types of information pieces about users to user.com app automatically, you should use the code snippet version for logged in users. You need to paste it just above the closing tag of the “” part of your website. This is just an example, so you need to add here only those attributes that you want to pass. The most important one is user_ id as this is a unique identifier of a user sent from your database. Thanks to the unique user_id, user.com app is able to save all information pieces about a given user in one user profile, even when they use multiple devices and different browsers (so different cookie files)! To put it short: thanks to unique user_id user.com provides you with cross-device tracking. Then, these elements on the right-hand side you see here are just placeholders and you need to replace them with variables that will communicate with the system or solution you use and find corresponding attributes’ values. Standard attributes will be passed straight away but if you want to pass custom attribute values through the widget, you need to create them first in your user.com app. You can do that directly from your app, by going to Settings -> App settings -> user data & events and “User attributes”. With that expanded version of code snippet added to your website code, if there is a new anonymous user at your site, the attribute values will simply be empty but the tracking will of course work for them as well. Just tell you IT team it should work in a way that if you have the attributes for users, they should be passed to user.com, if there are no attributes - they shouldn’t be passed. They’ll know exactly what to do here! One more thing to remember about is making sure that the API key and your app domain are correct. As you see, it has been added automatically to the snippets but in case you want to double check, you can always access your API key and domain at the top of main “Setup & integrations” section. Those values will be different for each app in user.com. So we’ve just discussed installing user.com by custom JavaScript. Thanks for listening!