Expand my Community achievements bar.

SOLVED

Best Practices: Tracking search terms and avoiding extra server calls

Avatar

Level 2

I need to track internal search terms, so I created a rule that triggers when a search is submitted. I also have a global page load rule to track all pageviews.

Now, when a user submits a search, there are two rules firing. One s.tl() rule for the search (sending search term, number of results and username) and a different s.t() rule for the page load (sending page name, URL and username)

Is this a best practice, or is there a way to simplify this process into a single rule/server call? Thanks for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 2

IMHO, best practice is to have those variables (search terms, number of results, etc) in the data layer of your search results page. Then you set them accordingly in your s.t() call on the search results page. Using this approach, you remove the need for the s.tl() call.

If you can't do the data layer, you can create a rule to store values in data elements/sessionstorage. On your search results page, call and set those values together with the s.t() call. This is more messy but ensures that you only need 1 call to track search terms and number of results.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 2

IMHO, best practice is to have those variables (search terms, number of results, etc) in the data layer of your search results page. Then you set them accordingly in your s.t() call on the search results page. Using this approach, you remove the need for the s.tl() call.

If you can't do the data layer, you can create a rule to store values in data elements/sessionstorage. On your search results page, call and set those values together with the s.t() call. This is more messy but ensures that you only need 1 call to track search terms and number of results.

Avatar

Level 10

If your goal is to minimize server calls, then yes, you could send the search term along with the s.t() call. There are numerous ways to capture and store the search term (local storage, cookie, hidden element, ect) so it's really up to you and your development team. Keep in mind you can also create rules in Launch that set variables but don't fire a beacon.