Skip to Main Content

Transformative Website Style Guide: Events and Google Tag Manager

This guide offers practical advice on creating a transformative library website.

Recommended Resources

Why Events?

Events provides the most in-depth information of how users are using your website. Is customizable for any situation, especially in conjunction with Google Tag Manager. Do you want to track outbound links (such as databases or chat services)?  Do you want to track search box usage? Events allows you to track specific user functions such as these.

Events and Google Tag Manager - Initial Setup

Incorporating Google Tag Manager with Google Analytics:

Google Tag Manager is a free Google product that works closely with but is independent of Google Analytics. It allows you to setup custom events for a variety of tracking purposes.

  • Setup Google Tag Manager:
    • Login to Google Tag Manager. Use the same Google login you use for Google Analytics.
    • In Google Tag Manager, Create Account. Name your Account (i.e. Library Website), then develop your first container (i.e. libguides.college.edu). You can have multiple containers under a account, which is great for tracking multiple sites such as LibGuides, your institutional site, etc.
    • Agree to Terms of Service.
    • Copy two pieces of code snippet into your website.
    • Publish Container.
  • Create a Tag to connect Google Analytics and Google Tag Manager:
    • Go to Google Analytics Admin.
      • Select the Property for your website.
      • Select Data Streams. If there is not a stream setup, select Add stream. If there is a stream, click on it.
      • Copy the Measurement ID.
    • Go to Google Tag Manager and your newly made container.
      • Select Workspace.
      • Select Tags, then New.
      • Under Tag Configuration, select the pencil in the upper right hand corner.
        • Select Google Analytics: GA4 Configuration.
        • Paste the Measurement ID.
      • In the Tag setup page, under Triggering select the pencil in the upper right hand corner.
        • Select the plus button right to the Firing Triggers
        • Under Choose a trigger, select the plus button.
        • Under Trigger Configuration, select the pencil in the upper right hand corner.
        • Under Choose trigger type, select Page View. Set this trigger to fire on All Page Views.
      • Publish the Container by selecting the Submit button in the upper right hand corner of the workstation.

Google Tag Manager expert Julius Fedorovicius of Analytics Mania provides frequently updated YouTube videos documenting how to implement Google Tag Manager with Google Analytics.

Events and Google Tag Manager - Tracking Outbound Links

Tracking Outbound Links

Are you curious about traffic to your subscription content? Setting up an event to track outbound links can do this! The final result will be the event outbound_links in the Event section of your Google Analytics property.

  • In Google Tag Manager, select your library website's Container. In it’s workspace select Variables (in the left hand column)     
    • Under User-Defined Variables, select New.
    • In the upper left hand corner, name your variable Outbound Links
    • Under Variable Configuration, click on the icon above the wording Choose a variable type to begin setup...         
      • Select Auto-Event Variable
      • Under the second Variable Type (with the drop-down), select Element URL
      • Under Component Type, select Is Outbound
      • Save changes, return to workspace
  • Setting up a Trigger
    • Under the options Choose a Trigger select the plus sign in the upper right hand corner.
    • Name your Trigger Outbound Links
    • Under Trigger Configuration, click on the icon above the wording Choose a trigger type to begin setup...
      • Select Just Links
    • Under This trigger fires on, select Some Link Clicks
    • Under Fire this trigger when an Event occurs and all of these conditions are true make the following statements:         
      • Outbound Links | equals | true
      • Outbound Links | does not contain | [your library website url]
    • Save changes, return to Workspace
  • Select New Tag (or select Tags in the left hand column, then New).     
    • Name your Tag Outbound Links
    • Under Tag Configuration, click on the icon above the wording Choose a tag type to begin setup...
      • Select Google Analytics: GA4 Event
      • Under Configuration Tag, select Google Analytics GA4 Configuration
      • Under Event Name, outbound_links (you can name this anything if you wish, it is simply the event you are going to look for in Google Analytics)
      • Under Event Parameters,             
        • for Parameter Name click on the Lego block and select Outbound Links
        • for Value click on the Lego block and select Click URL
    • A pop up box will inform you No Triggers Selected. Select Add Trigger      
  • Make sure it works! Preview changes.    
    • In the Workspace, click Preview (upper right hand corner).
    • A new tab will open with a pop up prompt Start Tag Assistant. Select Connect.
    • Another new tab will open with your website. Test your setup by clicking onto an outbound link. (For example, go to your All Databases A-Z list page and select a database).
  • Make sure it really works. Test in Google Analytics.
    • Open Google Analytics and your website’s Property
    • On the lower left hand column select Configure, then DeBug View
    • If you have just ran a test in Google Tag Manager preview, look for the vertical timeline in the middle of page for recent visits, and look for the event outbound_links.
    • If you see the event, congratulations you have successfully set this up.

 

Events and Google Tag Manager - Tracking Search Box Buttons

Search Box Click

This tracks when someone clicks / taps into the search box. For specifics on how to create variables, triggers, and tags, please look at the box Tracking Search Box Buttons above.

Variable: Use the existing variable:

  • Click Classes

Trigger: Create a new trigger with the following:

  • Name: Name this whatever you would like. Recommendation: Search Box Click
  • Trigger Type: Click - All Elements
  • This trigger fires on: Some Clicks
  • Find this trigger when an Event occurs and all of these conditions are true (select the following)
  • Click Classes
  • Contains
  • [open box right of Contains]: Find the “class” element in the HTML of the search box. To do so, open a new browser tab/window and open the page with the search box you want to track. Click in the search box, right click and select Inspect, then for the “class” element
  • Example:
  • Class element in the example is “search-bar-input”

Tag: Create a new tag with the following:

  • Name: Name this whatever you would like. Recommendation: Search Box Click
  • Tag Type: Google Analytics: GA4 Event
  • Configuration Tag: Google Analytics GA4 Configuration
  • Event Name: Name this whatever you would like. Recommendation: search_box_click
  • Triggering. Firing Triggers: Select the trigger made above

Search Box Tab

This tracks when someone clicks / taps a specific tab of a search box

Variable: Use the existing variable:

  • Click URL

Trigger: Create a new trigger with the following:

  • Name: Name this whatever you would like. Recommendation: Search Box [tab name] Tab
  • Trigger Type: Click - All Elements
  • This trigger fires on: Some Clicks
  • Find this trigger when an Event occurs and all of these conditions are true (select the following)
  • Click Classes
  • equals
  • [open box right of equals]: Find the URL of the search box tab. To find, right click on the search box tab, select Copy Link

Tag: Create a new tag with the following:

  • Name: Name this whatever you would like. Recommendation: Search Box [tab name] Tab
  • Tag Type: Google Analytics: GA4 Event
  • Configuration Tag: Google Analytics GA4 Configuration
  • Event Name: Name this whatever you would like. Recommendation: search_box_[name of tab]_tab
  • Triggering. Firing Triggers: Select the trigger made above

Search Box Submission

This tracks when someone conducts a search from a search box

Variable: Use the existing variable:

  • Click URL

Trigger: Create a new trigger with the following:

  • Name: Name this whatever you would like. Recommendation: Search Box Submission
  • Trigger Type: Form Submission
  • This trigger fires on: Some Forms
  • Find this trigger when an Event occurs and all of these conditions are true (select the following)
  • Click URL
  • contains
  • [open box right of contains]: Find the “action” element in the HTML of the search form. To do so, open a new browser tab/window and open the page with the search box you want to track. Click in the search box, right click and select Inspect, then for the “action” element, which might be above or below the input line of code highlighted
  • Example:
  • Class element in the example is “https://goshen.on.worldcat.org/search”

Tag: Create a new tag with the following:

  • Name: Name this whatever you would like. Recommendation: Search Box Submission
  • Tag Type: Google Analytics: GA4 Event
  • Configuration Tag: Google Analytics GA4 Configuration
  • Event Name: Name this whatever you would like. Recommendation: search_box_submission
  • Triggering. Firing Triggers: Select the trigger made above