How can I track search pages terms with Zaraz?

I want to track search terms for the search pages with Zaraz Google Analytics 4 tool. My search query parameter is s (e.g. /?s=Cloudflare). Here’s my settings to achieve that-


Is that all? Not getting search terms with that. What can I do?

Hey there, thanks for reaching out about this.

As an immediate fix for your usecase, you could update your search trigger to instead check for whether {{ system.page.url.href }} contains s=.
Your action then needs to send the value of query, {{ system.page.query.s }}, as a custom field called search_term.

Longterm, we should update the list of available fields to include the search term field by default (thanks for flagging); and try to make integration with GA4’s site search feature more intuitive.

Hope that helps

Thanks for the great reply!

Action search_term field with {{ system.page.query.s }} is working perfect.

But triggers working with my previous entries:

Match rule {{ system.page.url.search }} Contains s

Thanks!

Just to clarify, {{ system.page.url.search }} on a page url like “https://developers.cloudflare.com/zaraz/reference/properties-reference/?cheese=brie&bread=rye” will return ?cheese=brie&bread=rye, which also contains s hence you might benefit from using s= as a match string value instead. Maybe even ?s= if you’re sure that it will always be the first query key in the url.

Glad it’s working for you now either way

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.