Track search terms with GTM

The Find programmes page in DreamApply includes a search box that allows applicants to search for programmes. You can track what users search for and analyze these terms in Google Analytics.

To do this, we will integrate DreamApply with Google Tag Manager, set up a tag to capture search terms from search interactions and send them to Google Analytics for reporting.

Programme catalog page

Before you begin

  • Make sure your Administrator account in DreamApply has the Superuser role.
  • Make sure you have an account and container in Google Tag Manager. For details, see Create an account and container in the Google documentation.
  • Make sure you have an account and a data stream in Google Analytics. For details, see Add a data stream in the Google documentation.

Step 1. Integrate with Google Tag Manager

First, we need to connect DreamApply to Google Tag Manager.

  1. In Google Tag Manager, open your container.

  2. At the top of the page, copy the container ID.

    Getting a Container ID
  3. In DreamApply, in the main menu, under System, select Settings.

  4. In the Analytics settings section, under Google Tag Manager, specify the ID for your container.

  5. At the top of the form, click Save changes.

    Specifying Google Tag Manager settings

Step 2. Enable built-in variables

Next, we need to enable a built-in variable in Google Tag Manager. This variable is required to pass information about the click event from the Find programmes page.

  1. In Google Tag Manager, go to Variables.
  2. Under Built-In Variables, click Configure and under Clicks, select Click Text.
Enabling variables

Step 3. Create a variable to capture search terms

The search box on the Find programmes page uses the ID by. We will create a variable to capture the text entered into this box.

  1. In Google Tag Manager, go to Variables.

  2. Click New and create a variable with the following settings:

    • Variable name: Search term
    • Variable type: DOM element
    • Selection method: ID
    • Element ID: by
    • Attribute name: value
Creating a variable to capture search terms

Step 4. Create a click trigger

Next, we will create a trigger that fires when a user clicks the Find programmes button.

  1. In Google Tag Manager, go to Triggers.

  2. Click New and create a trigger with the following settings:

    • Trigger name: Find programmes click
    • Trigger type: Click - All Elements
    • Trigger fires on: Some Clicks
    • Condition: {{Click Text}} contains Find programmes
  3. In the top right corner, click Save.

Setting a trigger

Step 5. Set up the GA4 configuration tag

We need to connect Google Tag Manager to a GA4 property. This step is required to send the reporting data from Google Tag Manager to Google Analytics.

  1. In Google Analytics, locate and copy the Measurement ID for your data stream. For details, see Measurement ID in the Google documentation.

    Getting a Measurement ID
  2. In Google Tag Manager, go to Tags.

  3. Click New and create a tag with the following settings:

    • Tag name: GA4 - Configuration
    • Tag type: Google Analytics > Google Tag (Load the Google tag associated with your Google Analytics stream)
    • Tag ID: The Measurement ID of your data stream in Google Analytics
    • Triggering: Initialization - All Pages
  4. In the top right corner, click Save.

Setting a configuration tag

Step 6. Create a GA4 event tag

Finally, we need to create a GA4 tag that will send the search term to Google Analytics whenever the Find programmes button is clicked.

  1. In Google Tag Manager, go to Tags.

  2. Click New and create a tag with the following settings:

    • Tag name: Search terms
    • Tag type: Google Analytics > GA4 Event
    • Measurement ID: The Measurement ID of your data stream in Google Analytics
    • Event name: search
  3. Under Event parameters, add the following parameter:

    • Parameter name: search_term
    • Value: {{Search term}}
  4. Under Triggering, select the Find programmes click trigger created in step 4.

  5. In the top right corner, click Save.

Setting an event tag

Step 7. Publish the GTM container

Once the tags are set up, we can publish the GTM container. In Google Tag Manager, click Submit, provide a version name and description and click Publish.

Step 8. Test and verify

Now, we can test the setup and verify the data is collected correctly.

  1. Open the DreamApply portal in a new browser window using Incognito mode.
  2. On the Find programmes page, enter search terms in the search box and click Find programmes.
  3. In Google Analytics, open Realtime overview and check the Event count widget.
  4. Look for the event name search and verify that the search_term parameter contains the typed values.
Viewing event data

Step 9. Register the search_term parameter

To use the search_term parameter in custom reports, you must register it as a custom dimension in Google Analytics.

  1. In Google Analytics, in the bottom left corner, go to Admin.

  2. Under Data display, select Custom definitions and create a dimension with the following settings:

    • Dimension name: Search term
    • Scope: Event
    • Event parameter: search_term
  3. In the top right corner, click Save.

Creating a custom definition

Step 10. Create a custom report

To analyze long-term data, we can set up a custom report in Google Analytics. The report will show a list of search terms and the number of times the terms were searched for.

Realtime reports in Google Analytics are available immediately. Standard reports may take up to 24-48 hours to begin displaying data after initial setup. For details, see Data freshness in the Google documentation.

  1. In Google Analytics, go to Explore and select Blank.

  2. In the left pane, under Variables > Dimensions, add:

    • Event name
    • Search term
  3. Under Metrics, add Event count.

  4. In the Settings tab (middle section), add:

    • Rows: Search term
    • Values: Event count
    • Cell type: Heat map
    • Filters: Event name exactly matches search
    • (Optional) Filters: Search term does not match regex ^$(to exclude empty entries)
Viewing a table report