The Data Layer Variable Name needs to be exactly as the ones below:
The main Action Types to be tracked are:
Create the data layer variables below and name them the same way as below for consistency:
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 job.city and job.name, then return job.city – job.name. 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.
function() {
if({{DLV – ZB – Job City}} && {{DLV – ZB – Job Name}}){
return {{DLV – ZB – Job Name}} + ‘ – ‘ + {{DLV – ZB – Job City}};
}
else return “”;
}
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.
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.
You can choose what you want to send into GA.
Create a custom event trigger with the event name Zmashbot firing on all custom events.
With Lookup tables you can change how the values of variables are seen in GA.
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.