Set-up Event ViewCategory in Google Tag Manager

When you want to start an automation when someone has viewed a specific category on your website. Do you use an event (trigger) based on ViewCategory. You can set this up in Google Tag Manager. You will go through the following steps:

  1. Set-up Variable
  2. Set-up Trigger
  3. Set-up Tag

1. Set-up Variable 

  1. Create a new variable with a recognizable name. An example could be Squeezely – Ecommerce Products.


  2. For Variable Type, choose DataLayer.


  3. Insert the name of the DataLayer variable, for example: ecommerce.detail.products. Check the name of your DataLayer, as this can vary per provider. By setting the default value Undefined, the value can be requested as an extra piece of security.


  4. Save the variable. This step is now complete.

2. Set-up Trigger

  1. Create a new trigger named Squeezely - Event - ViewCategory


  2. Choose Trigger type: Custom Event


  3. Add the Custom Event name of view_item. By the way, check the correct event name via debug mode, because this depends on your DataLayer/Plugin.


  4. Save the trigger.

3. Set-up Tag

  1. Create a new tag named Squeezely - ViewContent.
  2. Choose Tag Type: Custom HTML. The code below pushes a ViewCategory event to Squeezely and passes the product object retrieved from the DataLayer.


    <script type="text/javascript">

    window._sqzl = window._sqzl || [];

    var product = {{Squeezely - DataLayer - Ecommerce Products}};

    "event" : "ViewCategory",
    "category_id" : product[0].category


  3. Select the trigger you created earlier.


    Once the trigger has gone off, you'll see the following in Squeezely under Data -> Live Events

    ViewCategory Data Live Events.png

    And the following on the visitor's profile:


    Please note that there may be a delay of about 2 minutes before the events are shown in Squeezely.