Troubleshooting

Site Search Tracking Not Working on WordPress

3 min read··By the TrackingCoder team
🔧

Common reasons search-usage tracking doesn’t fire

  1. GTM container not published - You imported the container but didn’t click Submit → Publish.
  2. GTM snippet not installed on your site - The GTM code needs to be in your site’s <head> and <body>.
  3. Search submits to a different URL - Many sites navigate to /search?q=... on submit. A Form Submission trigger won’t catch this - it’s effectively a Page View. Use a Page View trigger filtered by Page Path = /search instead, with the search term pulled from the q URL parameter.
  4. AJAX search with no navigation - Modern site search (Algolia, Typesense, instant search) updates results in place without changing the URL. A Page View trigger won’t fire. You need a Custom Event triggered by a DOM listener on the search input’s input or submit events (debounced).
  5. Search input is in a popover / modal - Click the search icon, the input element is created on the fly. A listener attached on DOM Ready won’t find it. Use event delegation: attach to document with a CSS-selector filter.
  6. Autocomplete suggestion clicked instead of full submit - Users often pick an autocomplete result rather than pressing Enter. That counts as a navigation, not a search. Decide whether to count autocomplete picks as searches; if yes, hook the autocomplete-pick event from your search vendor.

Step-by-step debugging checklist

  1. Verify GTM is installed - Visit your site, right-click → View Page Source, search for “GTM-”. If you don’t see it, GTM isn’t installed.
  2. Check GTM Preview mode - In GTM, click Preview. Navigate your site and trigger the event. Look for your tag in the Tags Fired section.
  3. Check the trigger - If the tag shows as “Not Fired”, click on it to see which trigger conditions aren’t met.
  4. Submit a search and watch the URL bar - Does the URL change to include ?q=... or similar? If yes: use a Page View trigger filtered by Page Path. If no: it’s AJAX - you need a Custom Event trigger.
  5. For AJAX: open the Network tab - Type a query. Look for an XHR / Fetch request to the search endpoint (e.g., algolia.net, /api/search). The request fires on every keystroke (debounced) - that’s your hook.
  6. For URL-param search: confirm the term is captured - Open GTM Preview, search for something. The Page URL variable should include ?q=yourquery. Use a URL variable in GTM to extract just the q param into a search_term dataLayer variable.

How to verify it’s working

  1. Open GTM Preview/Debug mode
  2. Navigate to your site
  3. Trigger the event (submit a search query)
  4. Check the GTM debug panel - your tag should appear under “Tags Fired”
  5. Check GA4 DebugView (GA4 → Admin → DebugView) to confirm the event arrived

Still didn’t work?

Our team can help. Describe what’s happening and we’ll get back to you within 24 hours.

Still didn't work? Report this issue

Fill in the details below and our team will review it within 3-5 business days. We aren't obliged to refund - but if we genuinely can't make it work, we may credit you back. Either way, your credits remain usable on a different event or site.

No need to type https:// - we'll add it for you.

Min 20 characters (0/20).

Context automatically included: search usage tracking on wordpress

Skip the manual setup

TrackingCoder detects your CMS and plugins automatically, then generates ready-to-use tracking code. No more adapting generic tutorials - get code tailored to your exact setup in under 2 minutes.

Try TrackingCoder Free →

2 free credits on signup. No card required.