Need help with searchjoy?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

ankane
491 Stars 50 Forks MIT License 220 Commits 1 Opened issues

Description

Search analytics made easy

Services available

!
?

Need anything else?

Contributors list

# 3,301
Ruby
Rails
chartjs
highcha...
204 commits
# 237,377
Shell
Redis
HTML
rich-te...
3 commits
# 34,459
PHP
Laravel
eloquen...
Crystal
2 commits
# 13,053
Elixir
Ruby
Rails
devise
1 commit
# 700,844
Ruby
JavaScr...
1 commit
# 385,225
JavaScr...
HTML
swatche...
vuejs-c...
1 commit
# 330,881
app-sto...
carthag...
Objecti...
cocoapo...
1 commit
# 636,452
JavaScr...
Ruby
1 commit
# 566,055
HTML
CSS
1 commit

Searchjoy

Search analytics made easy

See it in action

Screenshot

  • view searches in real-time
  • track conversions week over week
  • monitor the performance of top searches

Works with any search platform, including Elasticsearch, Sphinx, and Solr

:cupid: An amazing companion to Searchkick

Build Status

Installation

Add this line to your application’s Gemfile:

gem "searchjoy"

And run the generator. This creates a migration to store searches.

rails generate searchjoy:install
rails db:migrate

Next, add the dashboard to your

config/routes.rb
.
mount Searchjoy::Engine, at: "searchjoy"

Be sure to protect the endpoint in production - see the Authentication section for ways to do this.

Track Searches

Track searches by creating a record in the database.

Searchjoy::Search.create(
  search_type: "Item", # typically the model name
  query: "apple",
  results_count: 12,
  user_id: 1
)

With Searchkick, you can use the

track
option to do this automatically.
Item.search("apple", track: {user_id: 1})

If you want to track more attributes, add them to the

searchjoy_searches
table.
add_column :searchjoy_searches, :source, :string

Then, pass the values to the

track
option.
Item.search("apple", track: {user_id: 1, source: "web"})

It’s that easy.

Track Conversions

First, choose a conversion metric. At Instacart, an item added to the cart from the search results page counts as a conversion.

Next, when a user searches, keep track of the search id. With Searchkick, you can get the id with:

results = Item.search("apple", track: true)
results.search.id

When a user converts, find the record and call

convert
.
search = Searchjoy::Search.find(params[:id])
search.convert

Better yet, record the model that converted.

search.convert(item)

Authentication

Don’t forget to protect the dashboard in production.

Devise

In your

config/routes.rb
:
authenticate :user, ->(user) { user.admin? } do
  mount Searchjoy::Engine, at: "searchjoy"
end

Basic Authentication

Set the following variables in your environment or an initializer.

ENV["SEARCHJOY_USERNAME"] = "andrew"
ENV["SEARCHJOY_PASSWORD"] = "secret"

Data Retention

Data should only be retained for as long as it’s needed. Delete older data with:

Searchjoy::Search.where("created_at < ?", 1.year.ago).in_batches.delete_all

You can use Rollup to aggregate important data before you do.

Searchjoy::Search.rollup("Searches")

Delete data for a specific user with:

Searchjoy::Search.where(user_id: 1).delete_all

Customize

To customize, create an initializer

config/initializers/searchjoy.rb
.

Change the time zone

Searchjoy.time_zone = "Pacific Time (US & Canada)" # defaults to Time.zone

Change the number of top searches shown

Searchjoy.top_searches = 500 # defaults to 100

Link to the search results

Searchjoy.query_url = ->(search) { Rails.application.routes.url_helpers.items_path(q: search.query) }

Add additional info to the query in the live stream

Searchjoy.query_name = ->(search) { "#{search.query} #{search.city}" }

Show the conversion name in the live stream

Searchjoy.conversion_name = ->(model) { model.name }

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development and testing:

git clone https://github.com/ankane/searchjoy.git
cd searchjoy
bundle install
bundle exec rake test

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.