Book a demo

All FAQ questions

Tracking chatbot events in GA

About the Data Layers and Data Layer Variables

How a data layer push looks like:

The Data Layer Variable Name needs to be exactly as the ones below:

  1. Event 
  2. actionType
  3. name
  4. city

The main Action Types to be tracked are:

  1. init – Chatbot is initialized (is only seen by the user so if the user does not do anything else on the website and directly leaves, it is considered a non-interaction hit.
  2. firstFlowInteraction – Chatbot has been interacted with for the first time.
  3. consent – the GDPR message has been accepted.
  4. saveApplication – the application has been submitted and the user finalized the entire flow.


Setting up the data layer variables


Create the data layer variables below and name them the same way as below for consistency:


Creating a Custom JavaScript Variable for Label


Because we cannot send in Job Name and Job City in 2 separate fields because of the constraint (having only Category, Action, Label in the event setup) we need to combine Job Name and Job City. We will send it into GA as “Job Name – Job City” and that will be the label.

The code below says that, if there are 2 variables found in the data layer push, specifically and, then return – Remember, GTM already is tracking these custom variables because you previously set them up. So, in the code, use the names you have used for your custom data layer variables as shown below.


  1. Create a Custom Javascript Variable and name it CJS – ZB – Event Label.


  1. Use this code and make sure that everything bold is the same as the names you’ve given your other variables:


function() {

if({{DLV – ZB – Job City}} && {{DLV – ZB – Job Name}}){

return {{DLV – ZB – Job Name}} + ‘ – ‘ + {{DLV – ZB – Job City}};


else return “”;



Non-interaction Hit bot.init


  1. Create another custom Javascript variable.
  2. Name it CJS – ZB – Interaction Hit
  3. Use the code:

function() {

return {{DLV – ZB – actionType}} === ‘bot_init’



GTM will consider that if the actionType is “bot.init” it will be a non-interaction hit. This ensures that we will be accurate with data regarding the bounce rate. If we would have not done this, then the bounce rate would be very low because the chatbot pops up automatically on desktop and would have been considered an Interaction hit.


Configuring the tag


A custom event tag has 3 main fields that track data and send it into GA, with a 4th one referring to non-interaction hits, which are usually set to False. Assign the variables you previously created as shown in the image above.

  1. Category: Is always Zmashbot
  2. Action
  3. Label
  4. Non-interaction Hit


You can choose what you want to send into GA.

  1. All information: Event name (ZmashBot), Action Type (actionType), Job Name (, Job City (
  2. Some information: Event name (ZmashBot), Action Type (actionType).


Creating the trigger


Create a custom event trigger with the event name Zmashbot firing on all custom events.


Showing data in GA


With Lookup tables you can change how the values of variables are seen in GA.

  1. Create a Lookup Table Variable (LT – ZB – Event Action) if you want to change how the inputs are shown in GA.
  2. Each variable you created will pull information from the Data layer pushes. All the setups so far will push data like the one below in GA.
  3. Select the Input variable as DLV – ZB – actionType from the dropdown.
  4. The inputs will be the actual possible contents of the variable and the outputs will be how you want the data displayed in GA under actionType.


Set the default value to the data layer variable that you created for actionType. This ensures that, if it happens that there will be a different actionType than the ones you covered in input and output, it will still retrieve it.