search Event

The search event tracks when a user performs an on-site search. This is valuable for understanding customer intent, popular keywords, and optimizing search results and content.

The search model

This model defines the structure for tracking site search behavior.

Properties

  • Name
    event
    Type
    string
    Description

    Must be set to search.

  • Name
    search_term
    Type
    string
    Description

    The keyword or phrase the user searched for.

  • Name
    user_id
    Type
    string
    Description

    ID of the user performing the search.

  • Name
    session_id
    Type
    string
    Description

    ID of the current session.


Push event to the dataLayer

dataLayer.push example

dataLayer.push({
  event: 'search',
  search_term: 'reusable water bottle',
  user_id: 'user-0001',
  session_id: 'session-abc123'
});

Best Practices

  • Fire this event after the search results are rendered, not just on form submission.
  • Sanitize search terms before pushing to avoid PII.
  • Use lowercase and trim unnecessary whitespace for consistency.

Use Cases

The search event supports:

  • Search experience optimization
  • SEO and merchandising analysis
  • Intent-based segmentation
  • Product and content strategy

Was this page helpful?