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.

    Variabele_aanmaken.png

  2. For Variable Type, choose DataLayer.

    Viewcontent_variabeletype.png

  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.

    Cntentview_Variabele_Config.png

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

2. Set-up Trigger

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

    ViewContent_trigger.png

  2. Choose Trigger type: Custom Event

    ViewContent_Custom.png

  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.

    ViewContent_Trigger_config.png

  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.

    ViewCategory_Script.png

    <script type="text/javascript">

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

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

    window._sqzl.push({
    "event" : "ViewCategory",
    "category_id" : product[0].category
    });

    </script>

  3. Select the trigger you created earlier.

    ViewCategory.png

    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:

    ViewCategory_Profile.png

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