Method: Klaviyo::Metrics.get_metric_export

Defined in:
lib/klaviyo/apis/metrics.rb

.get_metric_export(metric_id, start_date: nil, end_date: nil, unit: nil, measurement: nil, where: nil, by: nil, count: nil, api_key: nil) ⇒ Object

Export event data, optionally filtering and segmented on available event properties

Parameters:

  • metric_id (String)

    the id of the metric

  • start_date (String) (defaults to: nil)

    Beginning of the timeframe to pull event data for. Default is 1 month ago

  • end_date (String) (defaults to: nil)

    End of the timeframe to pull event data for. Default is the current day

  • unit (String) (defaults to: nil)

    Granularity to bucket data points into - one of ‘day’, ‘week’, or ‘month’. Defaults to ‘day’.

  • measurement (String or JSON-encoded list) (defaults to: nil)

    Type of metric to fetch

  • where (JSON-encoded list) (defaults to: nil)

    Conditions to use to filter the set of events. A max of 1 condition can be given.

  • by (String) (defaults to: nil)

    The name of a property to segment the event data on. Where and by parameters cannot be specified at the same time.

  • count (Integer) (defaults to: nil)

    Maximum number of segments to return. The default value is 25.

Returns:

  • A dictionary relecting the input request parameters as well as a results property



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/klaviyo/apis/metrics.rb', line 62

def self.get_metric_export(metric_id,
                           start_date: nil,
                           end_date: nil,
                           unit: nil,
                           measurement: nil,
                           where: nil,
                           by: nil,
                           count: nil,
                           api_key: nil
                           )
  path = "#{METRIC}/#{metric_id}/#{EXPORT}"
  params = {
    :start_date => start_date,
    :end_date => end_date,
    :unit => unit,
    :measurement => measurement,
    :where => where,
    :by => by,
    :count => count
  }
  v1_request(HTTP_GET, path, api_key: api_key, **params)
end