Articles on: Developers

How to leverage contact data in Crisp thanks to Google Tag Manager

In this article, we're going to see how you can use the DataLayer to activate some features as for example a chat support, that you can only display to a specific user base.

For example, at Crisp, we could choose to only offer live chat support to users that are not under the basic plan. (which will never be the case, don't worry).

Through this article, we will guide you on how you can take advantage of user attributes (also known as custom data or conversation data) to display the chatbox based on what the user has subscribed to.

Using Google Tag Manager will help you to do this on your own, without any coding skills required. Prior to this, just make sure that you have custom data that are set on each user profile.

Note that custom data can also be set using our APIs or simply by importing a CSV file.

How to use the DataLayer?



To be autonomous, you need to know what is the plan my user has subscribed to and how much he pays each month.

For example, you can add this to your existing JS template :

<script>
  window.dataLayer = window.dataLayer || [];

  window.dataLayer.push({
    typePlan: 'Unlimited',
    price: '95'
  });
</script>


Don't forget to make your data dynamic by using variables for typePlan or price. You can even modify them as much as you want to trigger a message on whatever event you're tracking.

Naturally, to make it work, you need to have the Crisp JS added to your website. If you don't, there are various ways to add Crisp to your website.

How to add triggers to display the chatbox to the right people ?



At first, you need to connect to your Google Tag Manager account and reach out to the variables section.



Once you're here, scroll down to the bottom of the page and create a new variable.



Now, click on new and create a "**DataLayer Variable**" that will contain the value of the variable you've just set through your existing JS template



Create a trigger to display the chat based on the data



And voilà! You can now display your chat based on user data. Don't get it wrong, you can set multiple user data to display the chat to the right people. It only depends on what you know on your customers.

This article has been initially written here by one of our customer. (beware, french content)

Updated on: 13/06/2022

Was this article helpful?

Share your feedback

Cancel

Thank you!