Learn business growth with Google Analytics 4 Forums Google Analytics 4 Implementing Website Search Tracking in GA4 with Google Tag Manager

  • Implementing Website Search Tracking in GA4 with Google Tag Manager

    Posted by Elizabeth on 13 June 2022 at 5:38 pm

    Hey, I need some assistance with Google Tag Manager (GTM). Up to this point, I haven’t been able to see the customer’s search term value in Google Analytics 4 (GA4).

    So here’s the deal, with the big Google-Update to GA4, we aren’t able to use special characters within search parameters anymore. This has caused some issues with TYPO3 extensions like ke_search.

    The search term pops up in the URL, for instance example.de/suche?tx_kesearch_pi[sword]=test. But as we can’t use our (TYPO3) search parameter tx_kesearch_pi1[sword] in GA4, we’re using GTM to manage an event for our website’s search terms. (Another way would be to rename the parameter in TypoScript, but in this case, we prefer doing it in GTM).

    Right, let’s dive into my approach. To track the search term, I’ve set up a new tag named “GA-4 Searchterm”. The tag type is a GA4-Event and its setup is based on the GA page view tag (all pages). I’ve picked search for the event name as Google suggests. For the event parameter, I’ve gone with search_term which is also recommended by Google. The value for this is my variable – I’ll talk about that just now.

    So, next up is the trigger.This is working perfectly (I’ve tested it with a few tools). Given that we have various domains in different languages, I’ve used Regex. The type is a “page view” which is triggered when the page url matches the Regex value. I’ve used the landing page name suche|search|buscar|recherche|ricerca for my url-pages like example.com/search.

    Now onto the variable. I have a hunch this is where something’s gone wrong. I’ve set it to URL and query type and for my search key, I´m using my parameter tx_kesearch_pi1[sword].

    The final step takes place in GA4 where I’ve created a User Defined Definition.

    I can see that Analytics is counting the retrieved event search_term but the problem is I can’t see its value i.e. Test-Search.

    Is there anyone who can help me out with this? Any help is greatly appreciated!

    Ashton replied 1 year, 4 months ago 3 Members · 2 Replies
  • 2 Replies
  • Aiden

    Member
    31 May 2023 at 5:37 am

    Sure, I’d be happy to help you out! This might actually be a pretty straightforward fix. Here’s what you can do:

    1. Let’s start with adding a Custom Definition. You can find how to do this using this reference link:
      Custom Definition

    2. Next, you’ll want to add a Data Exploration. Check out this handy reference for that:
      Data Exploration

    And that’s it! Let’s give that a try and see if it solves your issue. If there’s anything else you need, just let me know. All the best!

  • Ashton

    Member
    4 July 2023 at 10:40 pm

    Based on your question, it seems like you’ve set up everything correctly but aren’t seeing the search term value appear in Google Analytics 4. This is most likely an issue with the variable configuration in Google Tag Manager.

    In your variable settings in GTM, you’re trying to get the value of the parameter ‘tx_kesearch_pi1[sword]’. However, according to the URL example you provided, the parameter in the URL is ‘tx_kesearch_pi[sword]’. There seems to be an extra ‘1’ in your GTM variable. This could be why GTM isn’t able to retrieve the correct search term value.

    Please update your GTM variable and change ‘tx_kesearch_pi1[sword]’ to ‘tx_kesearch_pi[sword]’. Test it again to see if the search term is correctly being sent to Google Analytics 4.

    If you’re still having problems after making this change, please check if you’re properly capturing the variable value in both the Tag and the Trigger settings. There might be an error in your Regex configuration, too.

    Remember that GTM is sensitive to changes, so make sure all the configurations are identical to your webpage URLs, parameter names, and Regex settings.

Log in to reply.