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: 

  1. Service Listing
  2. Book Appointment Button
  3. Confirm Booking Button
  4. Thank You page

To create the service listing variable

  1. Log in to Google Tag Manager.
    Google Tag Manager dashboard appears. 
  2. Select Variables in the side menu.
    The Built-In Variables table appears.
  3. Scroll down to click New.
    Untitled Variable page appears.
  4. Name the variable as Service Listing
  5. Select Custom Javascript as the Variable Type.
    Custom Javascript code box appears.
  6. 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

  1. Log in to Google Tag Manager.
    Google Tag Manager dashboard appears. 
  2. Select Variables in the side menu.
    The Built-In Variables table appears.
  3. Scroll down to click New.
    Untitled Variable page appears.
  4. Name the variable as Book Appointment Button
  5. Select Custom Javascript as the Variable Type.
    Custom Javascript code box appears.
  6. 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

  1. Log in to Google Tag Manager.
    Google Tag Manager dashboard appears. 
  2. Select Variables in the side menu.
    The Built-In Variables table appears.
  3. Scroll down to click New.
    Untitled Variable page appears.
  4. Name the variable as Confirm Booking Button
  5. Select Custom Javascript as the Variable Type.
    Custom Javascript code box appears.
  6. 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

  1. Log in to Google Tag Manager.
    Google Tag Manager dashboard appears. 
  2. Select Variables in the side menu.
    The Built-In Variables table appears.
  3. Scroll down to click New.
    Untitled Variable page appears.
  4. Name the variable as Thank You page
  5. Select Custom Javascript as the Variable Type.
    Custom Javascript code box appears.
  6. 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

Add Google Tag Manager to your Webstore

Did this answer your question?