Coder Social home page Coder Social logo

searchjoy's Introduction

Searchjoy

Search analytics made easy

See it in action

  • 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

💘 An amazing companion to Searchkick

Get Started

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
rake db:migrate

Next, add the dashboard to your config/routes.rb.

mount Searchjoy::Engine, at: "admin/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. 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.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.

item = Item.find(params[:item_id])
search.convert(item)

Authentication

Don’t forget to protect the dashboard in production.

Basic Authentication

Set the following variables in your environment or an initializer.

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

Devise

In your config/routes.rb:

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

Customize

Time Zone

To change the time zone, create an initializer config/initializers/searchjoy.rb with:

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

Top Searches

Change the number of top searches shown with:

Searchjoy.top_searches = 500 # defaults to 100

Live Conversions

Show the conversion name in the live stream.

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

TODO

  • customize views
  • analytics for individual queries
  • group similar queries
  • track pagination, facets, sorting, etc

Contributing

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

searchjoy's People

Contributors

amalrik avatar ankane avatar ckorhonen avatar dora0825 avatar dwightwatson avatar patrick-nits avatar tegon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.