Module: Swiftype::Client::Analytics

Included in:
Swiftype::Client
Defined in:
lib/swiftype/client.rb

Overview

The analytics API provides a way to export analytics data similar to what is found in the Swiftype Dashboard. See the REST API Documentation for details.

Instance Method Summary collapse

Instance Method Details

#analytics_autoselects(engine_id, options = {}) ⇒ Object

Return the number of autoselects (when a user clicks a result from an autocomplete dropdown) that occurred on each day in the time range for the provided Engine and optional DocumentType. The maximum time range between start and end dates is 30 days.

Parameters:

  • engine_id (String)

    the Engine slug or ID

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :document_type_id (String)

    the DocumentType slug or ID

  • :start_date (String)

    a date formatted like '2013-01-01'

  • :end_date (String)

    to a date formatted like '2013-01-01'


404
405
406
407
408
409
410
411
# File 'lib/swiftype/client.rb', line 404

def analytics_autoselects(engine_id, options={})
  document_type_id = options.delete(:document_type_id)
  if document_type_id
    get("engines/#{engine_id}/document_types/#{document_type_id}/analytics/autoselects.json", options)
  else
    get("engines/#{engine_id}/analytics/autoselects.json", options)
  end
end

#analytics_clicks(engine_id, options = {}) ⇒ Object

Return the number of clickthroughs (when a user clicks a result from a search results page) that occurred on each day in the time range for the provided Engine and optional DocumentType. The maximum time range between start and end dates is 30 days.

Parameters:

  • engine_id (String)

    the Engine slug or ID

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :document_type_id (String)

    the DocumentType slug or ID

  • :start_date (String)

    a date formatted like '2013-01-01'

  • :end_date (String)

    to a date formatted like '2013-01-01'


422
423
424
425
426
427
428
429
# File 'lib/swiftype/client.rb', line 422

def analytics_clicks(engine_id, options={})
  document_type_id = options.delete(:document_type_id)
  if document_type_id
    get("engines/#{engine_id}/document_types/#{document_type_id}/analytics/clicks.json", options)
  else
    get("engines/#{engine_id}/analytics/clicks.json", options)
  end
end

#analytics_searches(engine_id, options = {}) ⇒ Object

Return the number of searches that occurred on each day in the time range for the provided Engine and optional DocumentType. The maximum time range between start and end dates is 30 days.

Parameters:

  • engine_id (String)

    the Engine slug or ID

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :document_type_id (String)

    the DocumentType slug or ID

  • :start_date (String)

    a date formatted like '2013-01-01'

  • :end_date (String)

    to a date formatted like '2013-01-01'


386
387
388
389
390
391
392
393
# File 'lib/swiftype/client.rb', line 386

def analytics_searches(engine_id, options={})
  document_type_id = options.delete(:document_type_id)
  if document_type_id
    get("engines/#{engine_id}/document_types/#{document_type_id}/analytics/searches.json", options)
  else
    get("engines/#{engine_id}/analytics/searches.json", options)
  end
end

#analytics_top_no_result_queries(engine_id, options = {}) ⇒ Object

Return top queries with no results for an engine.

Parameters:

  • engine_id (String)

    the engine slug or ID

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :start_date (String)

    a date formatted like '2013-01-01'

  • :end_date (String)

    a date formatted like '2013-01-01'

  • :page (Integer)

    page number. The server defaults to page 1 and the maximum is 50.

  • :per_page (Integer)

    number of results per page. The server defaults to 20 and the maximum is 100.


451
452
453
# File 'lib/swiftype/client.rb', line 451

def analytics_top_no_result_queries(engine_id, options={})
  get("engines/#{engine_id}/analytics/top_no_result_queries.json", options)
end

#analytics_top_queries(engine_id, options = {}) ⇒ Object

Return top queries for an engine.

Parameters:

  • engine_id (String)

    the engine slug or ID

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :start_date (String)

    a date formatted like '2013-01-01'

  • :end_date (String)

    a date formatted like '2013-01-01'

  • :page (Integer)

    page number. The server defaults to page 1 and the maximum is 50.

  • :per_page (Integer)

    number of results per page. The server defaults to 20 and the maximum is 100.


439
440
441
# File 'lib/swiftype/client.rb', line 439

def analytics_top_queries(engine_id, options={})
  get("engines/#{engine_id}/analytics/top_queries.json", options)
end