Because AddSearch utilises search-as-you-type functionality, you need to disable the default Site search tracking in your Google analytics. Follow the instructions to do that:
If you are serving Google Analytics as a Google Tag Manager (GTM) tag, some additional steps are required for Google Analytics integration to work.
Set up variables
Sign in to your Google Tag Manager account
Click on Variables from the left-hand side menu
Under User-Defined Variables, click New
Click on the variable configuration and choose Data Layer Variable
Enter “view_or_click” under “Data Layer Variable Name”
Click Save and enter view_or_click as a name for the variable
Create two more variables, search_term and num_results, following the same steps. You should have three new variables once this step is finished.
Create a trigger
Sign in to your Google Tag Manager account
Click on Triggers from the left-hand side menu
Click on the New button
Click on the trigger configuration and choose Custom Event
Enter view_search_results under “Event name”
Click Save and enter view_search_results as a name for the trigger
Create a tag
Sign in to your Google Tag Manager account
Click on Tags from the left-hand side menu
Select the New option
Click on the trigger configuration and choose view_search_results trigger created in the previous step
Click on the tag configuration and select Google Analytics: GA4 Event
Open the Select Configuration Tag… menu and choose an existing tag or “Manually Set ID” if you don’t have any in the dropdown list
If you choose the “Manually Set ID” option, enter your GA4 Measurement ID that has the following format: G-XXXXXXXXXX
Enter view_search_results under the “Event name”
In the event parameters, you need to enter three previously created variables as shown in the screenshot
Then click Save and use view_search_results as the tag name
Publish your changes, and the search events should start showing in your Google Analytics account. Here is how the tag configuration should look like once the setup is complete:
Was this helpful?
Let us know if you liked the post. That’s the only way we can improve.