Forum Academy Marketplace Showcase Pricing Features

Incrementing a database entry based on user action

I’m trying to implement search results page analytics for my marketplace. Basically, whenever a visitor searches and then clicks on a listing, I want to increment the clicks count against the corresponding search term for that seller. (Database “things” are shown in italics).

I have a Seller as a database type, and each Seller has associated with their database entry, a list of search terms and the corresponding number of clicks for that term. The search terms entry is called search term and is type text, while the clicks is stored in count which is of type number.

I’m trying to do this using the Workflow called Make Changes to a Thing, but I’m not having much success. I can’t seem to find a simple way to increment the count by 1 whenever someone clicks on the corresponsing search result.

Hi @sandeep.jaykumar,

Is count a field on search term thing or is it a seperate thing?

Either way, you should be able to achieve the right result with “Make changes to a thing” fired on the search result listing click. Please share how you’ve tried to set it up so far so we can help :slightly_smiling_face:

Hi Alan, please ignore the names of Database things mentioned in my eariler post above. Below are the actual names.

I’ve got the following Data Types:

The SERP Analytics data type contains ID (of type text) and SERP Hits (of type Hits).
The Hits data type contains Clicks (of type number) and Search Query (of type text).

Whenever a visitor searches via the text search box, it should increment the Clicks count against the appropriate Search Query stored in the database, based on the seller’s ID.

For example, if a visitor types “shoes” and then sees Seller 1 with Nike shoes and Seller 2 with Adidas shoes, and if the visitor clicks on Nike shoes, then the Clicks count against the Search Query “shoes” of Seller 1 should increment by 1. If the term “shoes” does not yet exist in the analytics database of Seller 1, it should be created and incremented by 1.

Hey Sandeep, theres a few things at play so I apologize for the lengthy response.

First, I suggest having the Hits connect to SERP Analytics and not vice versa. I am of the mindset sub categories link to master categories.

Here is how I understand your process:
Step 1: user searches the term ‘shoes’
Step 2: user clicks on Seller 1s results which are ‘Nike’
Step 3: In the Hits table, Clicks for Shoes increases by 1 for that seller
Step 3b: If shoes doesnt exist for Seller1, create a new hits and set clicks to 1, and search query to shoes.

I am assuming after a user “searches” their term, the results are populated via a repeating group. Inside the RG there is a Group element that stores the basic display info for the shoes. If so, here is what I would do:

  • Create a workflow for the Group element “when Group is clicked”
  • "Make changes to: Do a search for Hits
  • Add a constraint, Search Queary = Searchbox value (the searchbox the user inputs into)
  • Add a second constraint, where you link hits to seller1 (as i mention earlier in the sub link to master)
  • Back at “do a search for” add :first item
  • Then click “change another field”
  • Change clicks to this Hits clicks +1
  • At the bottom, set ‘only when’ to happen if the search:exists or is not empty.
  • Create an identical workflow, except have it make a new hits data type only when the above search does not exist.

Sorry for the ramble, but hopefully this sets you on the right path. Let me know if you’re still having troubles and I can help further.

1 Like

Hi Bek, thanks a ton for the detailed reply! It was a real life-saver.

I’m almost there. I just had some problems with the is-empty evaluator, which looks like a bug to me, so I’m reporting it.

Its possible is-empty is not a valid vield in that situation, so you can probably play around with it by doing something like: “do a search for…:count <1” instead of ‘is empty’.