def stringify_keys(object)
      case object
      when Hash
        object.each_with_object({}) do |(key, value), result|
          result[key.to_s] = stringify_keys(value)
        end
      when Array
        object.map { |e| stringify_keys(e) }
      else
        object
      end
    end
def stringify_keys(object)
      case object
      when Hash
        object.each_with_object({}) do |(key, value), result|
          result[key.to_s] = stringify_keys(value)
        end
      when Array
        object.map { |e| stringify_keys(e) }
      else
        object
      end
    end
The keys have to be strings to get converted to a GA query.
 Adapted from Rails.