---
title: Clientside GTM search tracking
description: When a user types in a search phrase in a text field, a search event should be fired after a small delay, in order to track the entire search phrase. We recommend a delay of 500ms after typing in the
---

[Skip to content](https://content.raptorservices.com/help-center/setup-search-tracking-with-clientside-gtm#main-content)

![raptor-qntm-logo\_horizontal\_gradient.png\]](https://content.raptorservices.com/hs-fs/hubfs/raptor-qntm-logo_horizontal_gradient.png?height=40&name=raptor-qntm-logo_horizontal_gradient.png)

Open main navigation

Close main navigation

- [Go to raptorservices.com](https://raptorservices.com/)

[Go to raptorservices.com](https://raptorservices.com/)

 Hello. How can we help you?

- There are no suggestions because the search field is empty.

1. [Help Center](https://content.raptorservices.com/help-center?hsLang=en)
2. [Site Search](https://content.raptorservices.com/help-center/site-search?hsLang=en)
3. [Search Tracking](https://content.raptorservices.com/help-center/site-search?hsLang=en#search-tracking)

# Clientside GTM search tracking

### `search` event

When a user types in a search phrase in a text field, a `search` event should be fired after a small delay, in order to track the entire search phrase. We recommend a delay of 500ms after typing in the search input field

You can add the search event to the datalayer like this:

```
dataLayer.push(   event:"search",   searchPhrase: "SEARCH_PHRASE_HERE");
```

 

#### Search field tracking example snippet

In order to wait for the user to stop typing the search query, you can set up an eventlistener on the search input field like this:

**[JSFiddle example](https://jsfiddle.net/dr8oq6vj/)**

**![](https://content.raptorservices.com/hs-fs/hubfs/image-png-Dec-17-2024-12-55-32-8783-PM.png?width=547&height=696&name=image-png-Dec-17-2024-12-55-32-8783-PM.png)**

### `searchclick` event

You should set up a click handler for the items in the search result, so when clicked, you push an event to the datalayer, containing the clicked item

*Notice that the parameter with the position of the clicked element in the search result is optional.*

```
dataLayer.push(   event:"searchclick",   searchResultClickedItem: {Object},   searchResultposition: POSITION_OF_CLICKED_ITEM (Optional));
```

 

### GTM setup

If you are using the Raptor GTM template called **Raptor Event Tracking** here is a guide to how you can set up the search tracking. 

The template can be found in the [Google Tag Manager Gallery](https://tagmanager.google.com/gallery/#/owners/RaptorServices/templates/raptor-gtm-eventtracking) 

#### Create variables for your search events datalayer

You will need the following variables, if you have followed the guide above:

- searchPhrase
- searchResultClickedItem
- searchResultPosition (optional)

#### Add a tag for `search`tracking

Select the **Raptor Event Tracking** template

![](https://content.raptorservices.com/hs-fs/hubfs/image-png-Nov-21-2024-12-27-47-9993-PM.png?width=688&height=326&name=image-png-Nov-21-2024-12-27-47-9993-PM.png)

Select the event type **Search**

**![](https://content.raptorservices.com/hs-fs/hubfs/image-png-Nov-21-2024-12-34-03-8228-PM.png?width=688&height=446&name=image-png-Nov-21-2024-12-34-03-8228-PM.png)**

Map the searchPhrase variable to a Raptor parameter

![](https://content.raptorservices.com/hs-fs/hubfs/image-png-Nov-21-2024-12-45-11-5524-PM.png?width=688&height=519&name=image-png-Nov-21-2024-12-45-11-5524-PM.png)

**NB:** The parameter numbers (p1,p2...) can differ, depending on your implementation.

Please refer to your implementation page in the controlpanel, in order to get the exact parameters to send in this event \<LINK HERE\>

#### Add a trigger for the tag

Set up a trigger that listens for the **search** event you added to to the datalayer previously. 

![](https://content.raptorservices.com/hs-fs/hubfs/image-png-Nov-21-2024-12-50-22-4796-PM.png?width=688&height=248&name=image-png-Nov-21-2024-12-50-22-4796-PM.png)

#### Add a tag for `searchclick` tracking

Add another tag, choosing the **Raptor Event Tracking** Template

Select the event type **Search Click**

**![](https://content.raptorservices.com/hs-fs/hubfs/image-png-Nov-21-2024-12-53-22-5792-PM.png?width=688&height=482&name=image-png-Nov-21-2024-12-53-22-5792-PM.png)**

Map the clicked product to the raptor tracking, by selecting the variable you created for the clicked item

![](https://content.raptorservices.com/hs-fs/hubfs/image-png-Nov-21-2024-12-56-46-3677-PM.png?width=688&height=335&name=image-png-Nov-21-2024-12-56-46-3677-PM.png)

Now, add the parameters by referencing the names of the properties in the mapped object:

![](https://content.raptorservices.com/hs-fs/hubfs/image-png-Nov-21-2024-01-00-51-1872-PM.png?width=688&height=494&name=image-png-Nov-21-2024-01-00-51-1872-PM.png)

**NB:** The parameter numbers (p1,p2...) can differ, depending on your implementation.

Please refer to your implementation page in the controlpanel, in order to get the exact parameters to send in this event \<LINK HERE\>

#### Add a trigger for the tag

Set up a trigger that listens for the **searchclick** event you added to to the datalayer previously. 

#### Test the tracking

Now you are done, and you can test the tracking by entering debug mode in GTM. You can check that the trackings are being sent correctly to Raptor, be going to the **Live Tracking** page in our controlpanel

 

- [Welcome to Raptor](https://content.raptorservices.com/help-center/welcome-to-raptor?hsLang=en#main-content)

    - [Introduction](https://content.raptorservices.com/help-center/welcome-to-raptor?hsLang=en#introduction)
- [Analytics & Insights](https://content.raptorservices.com/help-center/analytics-insights?hsLang=en)
- [Data Management](https://content.raptorservices.com/help-center/data-management?hsLang=en#main-content)

    - [Implementing Tracking](https://content.raptorservices.com/help-center/data-management?hsLang=en#implementing-tracking)
    - [Implementing Raptor Recommendation](https://content.raptorservices.com/help-center/data-management?hsLang=en#implementing-raptor-recommendation)
    - [Email Marketing Integration](https://content.raptorservices.com/help-center/data-management?hsLang=en#email-marketing-integration)
    - [The Data Manager](https://content.raptorservices.com/help-center/data-management?hsLang=en#the-data-manager)
    - [Streaming API](https://content.raptorservices.com/help-center/data-management?hsLang=en#streaming-api)
    - [Destinations](https://content.raptorservices.com/help-center/data-management?hsLang=en#destinations)
- [Customer Data Platform](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#main-content)

    - [Introduction](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#introduction)
    - [Profile Unification](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#profile-unification)
    - [Audience Builder](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#audience-builder)
    - [Audience Insights](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#audience-insights)
    - [Calculated Attributes](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#calculated-attributes)
    - [Activations](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#activations)
    - [Single Customer View](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#single-customer-view)
    - [CDP Export API](https://content.raptorservices.com/help-center/customer-data-platform?hsLang=en#cdp-export-api)
- [Website Recommendations](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#main-content)

    - [Introduction](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#introduction)
    - [Recommendation Strategies](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#recommendation-strategies)
    - [Feeds](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#feeds)
    - [Tuning Parameters](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#tuning-parameters)
    - [Working with the Raptor API](https://content.raptorservices.com/help-center/website-recommendations?hsLang=en#working-with-the-raptor-api)
- [Mail Recommendations](https://content.raptorservices.com/help-center/mail-recommendations?hsLang=en)
- [E-mail Triggers](https://content.raptorservices.com/help-center/e-mail-triggers?hsLang=en#main-content)

    - [Get started](https://content.raptorservices.com/help-center/e-mail-triggers?hsLang=en#get-started)
    - [E-mail Trigger Documentation](https://content.raptorservices.com/help-center/e-mail-triggers?hsLang=en#e-mail-trigger-documentation)
    - [E-mail trigger integrations](https://content.raptorservices.com/help-center/e-mail-triggers?hsLang=en#e-mail-trigger-integrations)
- [Site Search](https://content.raptorservices.com/help-center/site-search?hsLang=en#main-content)

    - [Search Tracking](https://content.raptorservices.com/help-center/site-search?hsLang=en#search-tracking)
    - [Introduction](https://content.raptorservices.com/help-center/site-search?hsLang=en#introduction)
    - [Implementing Site Search](https://content.raptorservices.com/help-center/site-search?hsLang=en#implementing-site-search)
    - [Search Ranking & Recommendations](https://content.raptorservices.com/help-center/site-search?hsLang=en#search-ranking-recommendations)
    - [Reporting](https://content.raptorservices.com/help-center/site-search?hsLang=en#reporting)
- [Merchandising](https://content.raptorservices.com/help-center/merchandising?hsLang=en#main-content)

    - [Introduction to Merchandising](https://content.raptorservices.com/help-center/merchandising?hsLang=en#introduction-to-merchandising)
    - [Boosted Campaigns](https://content.raptorservices.com/help-center/merchandising?hsLang=en#boosted-campaigns)
    - [Customized Feeds](https://content.raptorservices.com/help-center/merchandising?hsLang=en#customized-feeds)
- [AI Models](https://content.raptorservices.com/help-center/ai-models?hsLang=en#main-content)

    - [Customer Lifetime Value](https://content.raptorservices.com/help-center/ai-models?hsLang=en#customer-lifetime-value)
- [Administration](https://content.raptorservices.com/help-center/administration?hsLang=en#main-content)

    - [Trust Center](https://content.raptorservices.com/help-center/administration?hsLang=en#trust-center)
    - [User Management](https://content.raptorservices.com/help-center/administration?hsLang=en#user-management)
    - [Operational Insights](https://content.raptorservices.com/help-center/administration?hsLang=en#operational-insights)
    - [Data Retention](https://content.raptorservices.com/help-center/administration?hsLang=en#data-retention)

[![Raptor Services](https://content.raptorservices.com/hubfs/Logo%20_By%20Ibexa%20-%20Color-Raptor.svg "Raptor Services")](https://www.raptorservices.com/)

raptorsmartadvisor.com Help Center

<https://www.linkedin.com/company/raptorservices/mycompany/> <https://www.instagram.com/raptorservices/>

Copyright © 2026, Raptor Services A/S