The variables in Google Tag Manager are named placeholders for values whose name will change. For example, you can assign a variable for tracking a Product Name, Price Value or a Date. For such elements, we create the variables and assign them to respective tags.
You must create the following variables to track the user behavior:
Service Listing
Book Appointment Button
Confirm Booking Button
Thank You page
To create the service listing variable
Log in to Google Tag Manager.
Google Tag Manager dashboard appears.Select Variables in the side menu.
The Built-In Variables table appears.Scroll down to click New.
Untitled Variable page appears.Name the variable as Service Listing.
Select Custom Javascript as the Variable Type.
Custom Javascript code box appears.Enter the following code in the code box.
function(){
return {
'ecommerce': {
'checkout': {
'actionField': {'step': 1},
}
}
}
}
7. Click Save.
The service listing variable is created.
Refer to the following image.
To create the book appointment button variable
Log in to Google Tag Manager.
Google Tag Manager dashboard appears.Select Variables in the side menu.
The Built-In Variables table appears.Scroll down to click New.
Untitled Variable page appears.Name the variable as Book Appointment Button.
Select Custom Javascript as the Variable Type.
Custom Javascript code box appears.Enter the following code in the box.
function(){
return {
'ecommerce': {
'checkout': {
'actionField': {'step': 2},
}
}
}
}
7. Click Save.
The book appointment button variable is now created.
To create a confirm booking button variable
Log in to Google Tag Manager.
Google Tag Manager dashboard appears.Select Variables in the side menu.
The Built-In Variables table appears.Scroll down to click New.
Untitled Variable page appears.Name the variable as Confirm Booking Button.
Select Custom Javascript as the Variable Type.
Custom Javascript code box appears.Enter the following code in the box.
function(){
return {
'ecommerce': {
'checkout': {
'actionField': {'step': 3},
}
}
}
}
7. Click Save.
The confirm booking button variable is now created.
To create thank you page variable
Log in to Google Tag Manager.
Google Tag Manager dashboard appears.Select Variables in the side menu.
The Built-In Variables table appears.Scroll down to click New.
Untitled Variable page appears.Name the variable as Thank You page.
Select Custom Javascript as the Variable Type.
Custom Javascript code box appears.Enter the following code in the box.
function(){
return {
'ecommerce': {
'checkout': {
'actionField': {'step': 4},
}
}
}
}
7. Click Save.
The Thank You page variable is now created.
Next Step: Create Tags for Tracking the Booking of an Appointment.
See Also