Rybbit
APIStats

Goals

Create and track conversion goals based on page visits or custom events

See the API Reference for authentication, common parameters, and filters.

Endpoints


Get Goals

GET /api/goals/:site

Returns a paginated list of goals with their conversion metrics.

Path Parameters

Prop

Type

Query Parameters

Accepts all Common Parameters plus the following:

Prop

Type

Response

Prop

Type

Goal Object

Prop

Type

GoalConfig Object

Prop

Type

Request
curl -X GET "https://api.rybbit.io/api/goals/123?start_date=2024-01-01&end_date=2024-01-31" \
  -H "Authorization: Bearer your_api_key_here"
Request
const response = await fetch(
  'https://api.rybbit.io/api/goals/123?start_date=2024-01-01&end_date=2024-01-31',
  {
    headers: {
      'Authorization': 'Bearer your_api_key_here'
    }
  }
);

const data = await response.json();
Request
import requests

response = requests.get(
    'https://api.rybbit.io/api/goals/123',
    params={
        'start_date': '2024-01-01',
        'end_date': '2024-01-31'
    },
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.rybbit.io/api/goals/123?start_date=2024-01-01&end_date=2024-01-31');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
Request
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://api.rybbit.io/api/goals/123?start_date=2024-01-01&end_date=2024-01-31')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer your_api_key_here'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(req)
end

data = JSON.parse(res.body)
Request
package main

import (
    "encoding/json"
    "io"
    "net/http"
)

func main() {
    url := "https://api.rybbit.io/api/goals/123?start_date=2024-01-01&end_date=2024-01-31"

    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Add("Authorization", "Bearer your_api_key_here")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)

    var data map[string]interface{}
    json.Unmarshal(body, &data)
}
Request
use reqwest;
use serde_json::Value;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();

    let response = client
        .get("https://api.rybbit.io/api/goals/123?start_date=2024-01-01&end_date=2024-01-31")
        .header("Authorization", "Bearer your_api_key_here")
        .send()
        .await?;

    let data: Value = response.json().await?;

    Ok(())
}
Request
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.rybbit.io/api/goals/123?start_date=2024-01-01&end_date=2024-01-31"))
            .header("Authorization", "Bearer your_api_key_here")
            .GET()
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        String data = response.body();
    }
}
Request
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        using var client = new HttpClient();

        client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

        var response = await client.GetAsync(
            "https://api.rybbit.io/api/goals/123?start_date=2024-01-01&end_date=2024-01-31");

        var data = await response.Content.ReadAsStringAsync();
    }
}
Response
{
  "data": [
    {
      "goalId": 1,
      "name": "Signup Completed",
      "goalType": "path",
      "config": {
        "pathPattern": "/signup/complete"
      },
      "createdAt": "2024-01-10T12:00:00.000Z",
      "total_conversions": 1250,
      "total_sessions": 15420,
      "conversion_rate": 0.081
    },
    {
      "goalId": 2,
      "name": "Purchase Made",
      "goalType": "event",
      "config": {
        "eventName": "purchase",
        "eventPropertyKey": "value",
        "eventPropertyValue": 100
      },
      "createdAt": "2024-01-15T09:30:00.000Z",
      "total_conversions": 320,
      "total_sessions": 15420,
      "conversion_rate": 0.021
    }
  ],
  "meta": {
    "total": 2,
    "page": 1,
    "pageSize": 10,
    "totalPages": 1
  }
}

Get Goal Sessions

GET /api/goals/:goalId/sessions/:site

Returns sessions that completed a specific goal. Useful for analyzing the behavior of converting users.

Path Parameters

Prop

Type

Query Parameters

Accepts all Common Parameters plus the following:

Prop

Type

Response

Prop

Type

Session Object

Prop

Type

Request
curl -X GET "https://api.rybbit.io/api/goals/1/sessions/123?page=1&limit=10" \
  -H "Authorization: Bearer your_api_key_here"
Request
const response = await fetch(
  'https://api.rybbit.io/api/goals/1/sessions/123?page=1&limit=10',
  {
    headers: {
      'Authorization': 'Bearer your_api_key_here'
    }
  }
);

const data = await response.json();
Request
import requests

response = requests.get(
    'https://api.rybbit.io/api/goals/1/sessions/123',
    params={
        'page': 1,
        'limit': 10
    },
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.rybbit.io/api/goals/1/sessions/123?page=1&limit=10');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
?>
Request
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://api.rybbit.io/api/goals/1/sessions/123?page=1&limit=10')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer your_api_key_here'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(req)
end

data = JSON.parse(res.body)
Request
package main

import (
    "encoding/json"
    "io"
    "net/http"
)

func main() {
    url := "https://api.rybbit.io/api/goals/1/sessions/123?page=1&limit=10"

    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Add("Authorization", "Bearer your_api_key_here")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)

    var data map[string]interface{}
    json.Unmarshal(body, &data)
}
Request
use reqwest;
use serde_json::Value;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();

    let response = client
        .get("https://api.rybbit.io/api/goals/1/sessions/123?page=1&limit=10")
        .header("Authorization", "Bearer your_api_key_here")
        .send()
        .await?;

    let data: Value = response.json().await?;

    Ok(())
}
Request
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.rybbit.io/api/goals/1/sessions/123?page=1&limit=10"))
            .header("Authorization", "Bearer your_api_key_here")
            .GET()
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        String data = response.body();
    }
}
Request
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        using var client = new HttpClient();

        client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

        var response = await client.GetAsync(
            "https://api.rybbit.io/api/goals/1/sessions/123?page=1&limit=10");

        var data = await response.Content.ReadAsStringAsync();
    }
}
Response
{
  "data": [
    {
      "session_id": "sess_abc123",
      "user_id": "user_xyz789",
      "country": "US",
      "browser": "Chrome",
      "operating_system": "macOS",
      "device_type": "desktop",
      "entry_page": "/",
      "exit_page": "/signup/complete",
      "pageviews": 5,
      "session_duration": 245,
      "session_start": "2024-01-31T14:00:00.000Z",
      "session_end": "2024-01-31T14:04:05.000Z",
      "referrer": "https://google.com",
      "channel": "organic"
    }
  ]
}

Create Goal

POST /api/goals/:site

Creates a new goal for tracking conversions.

Path Parameters

Prop

Type

Request Body

Prop

Type

GoalConfig for Path Goals

Prop

Type

GoalConfig for Event Goals

Prop

Type

Response

Prop

Type

Path Goal
curl -X POST "https://api.rybbit.io/api/goals/123" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Checkout Complete",
    "goalType": "path",
    "config": {
      "pathPattern": "/checkout/success"
    }
  }'
Event Goal
const response = await fetch(
  'https://api.rybbit.io/api/goals/123',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Purchase Made',
      goalType: 'event',
      config: {
        eventName: 'purchase',
        eventPropertyKey: 'plan',
        eventPropertyValue: 'pro'
      }
    })
  }
);

const data = await response.json();
Request
import requests

response = requests.post(
    'https://api.rybbit.io/api/goals/123',
    json={
        'name': 'Signup Complete',
        'goalType': 'path',
        'config': {
            'pathPattern': '/signup/*'
        }
    },
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
$body = [
    'name' => 'Checkout Complete',
    'goalType' => 'path',
    'config' => [
        'pathPattern' => '/checkout/success'
    ]
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.rybbit.io/api/goals/123');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here',
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
Request
require 'net/http'
require 'json'

uri = URI('https://api.rybbit.io/api/goals/123')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer your_api_key_here'
request['Content-Type'] = 'application/json'
request.body = {
  name: 'Checkout Complete',
  goalType: 'path',
  config: { pathPattern: '/checkout/success' }
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
Request
body := map[string]interface{}{
    "name": "Checkout Complete",
    "goalType": "path",
    "config": map[string]string{
        "pathPattern": "/checkout/success",
    },
}
jsonBody, _ := json.Marshal(body)

req, _ := http.NewRequest("POST", "https://api.rybbit.io/api/goals/123", bytes.NewBuffer(jsonBody))
req.Header.Set("Authorization", "Bearer your_api_key_here")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
Request
let body = serde_json::json!({
    "name": "Checkout Complete",
    "goalType": "path",
    "config": {
        "pathPattern": "/checkout/success"
    }
});

let client = reqwest::Client::new();
let res = client
    .post("https://api.rybbit.io/api/goals/123")
    .header("Authorization", "Bearer your_api_key_here")
    .json(&body)
    .send()
    .await?;

let data: serde_json::Value = res.json().await?;
Request
String json = """
{
  "name": "Checkout Complete",
  "goalType": "path",
  "config": {
    "pathPattern": "/checkout/success"
  }
}
""";

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.rybbit.io/api/goals/123"))
    .header("Authorization", "Bearer your_api_key_here")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request
var body = new
{
    name = "Checkout Complete",
    goalType = "path",
    config = new { pathPattern = "/checkout/success" }
};

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

var content = new StringContent(
    JsonSerializer.Serialize(body),
    Encoding.UTF8,
    "application/json");

var response = await client.PostAsync("https://api.rybbit.io/api/goals/123", content);
var data = await response.Content.ReadAsStringAsync();
Response
{
  "success": true,
  "goalId": 3
}

Update Goal

PUT /api/goals/:goalId/:site

Updates an existing goal.

Path Parameters

Prop

Type

Request Body

Prop

Type

Response

Prop

Type

Request
curl -X PUT "https://api.rybbit.io/api/goals/1/123" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Signup Completed (Updated)",
    "goalType": "path",
    "config": {
      "pathPattern": "/signup/complete/*"
    }
  }'
Request
const response = await fetch(
  'https://api.rybbit.io/api/goals/1/123',
  {
    method: 'PUT',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Signup Completed (Updated)',
      goalType: 'path',
      config: {
        pathPattern: '/signup/complete/*'
      }
    })
  }
);

const data = await response.json();
Request
import requests

response = requests.put(
    'https://api.rybbit.io/api/goals/1/123',
    json={
        'name': 'Signup Completed (Updated)',
        'goalType': 'path',
        'config': {
            'pathPattern': '/signup/complete/*'
        }
    },
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
$body = [
    'name' => 'Signup Completed (Updated)',
    'goalType' => 'path',
    'config' => [
        'pathPattern' => '/signup/complete/*'
    ]
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.rybbit.io/api/goals/1/123');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here',
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
Request
require 'net/http'
require 'json'

uri = URI('https://api.rybbit.io/api/goals/1/123')
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer your_api_key_here'
request['Content-Type'] = 'application/json'
request.body = {
  name: 'Signup Completed (Updated)',
  goalType: 'path',
  config: { pathPattern: '/signup/complete/*' }
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
Request
body := map[string]interface{}{
    "name": "Signup Completed (Updated)",
    "goalType": "path",
    "config": map[string]string{
        "pathPattern": "/signup/complete/*",
    },
}
jsonBody, _ := json.Marshal(body)

req, _ := http.NewRequest("PUT", "https://api.rybbit.io/api/goals/1/123", bytes.NewBuffer(jsonBody))
req.Header.Set("Authorization", "Bearer your_api_key_here")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
Request
let body = serde_json::json!({
    "name": "Signup Completed (Updated)",
    "goalType": "path",
    "config": {
        "pathPattern": "/signup/complete/*"
    }
});

let client = reqwest::Client::new();
let res = client
    .put("https://api.rybbit.io/api/goals/1/123")
    .header("Authorization", "Bearer your_api_key_here")
    .json(&body)
    .send()
    .await?;

let data: serde_json::Value = res.json().await?;
Request
String json = """
{
  "name": "Signup Completed (Updated)",
  "goalType": "path",
  "config": {
    "pathPattern": "/signup/complete/*"
  }
}
""";

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.rybbit.io/api/goals/1/123"))
    .header("Authorization", "Bearer your_api_key_here")
    .header("Content-Type", "application/json")
    .PUT(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request
var body = new
{
    name = "Signup Completed (Updated)",
    goalType = "path",
    config = new { pathPattern = "/signup/complete/*" }
};

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

var content = new StringContent(
    JsonSerializer.Serialize(body),
    Encoding.UTF8,
    "application/json");

var response = await client.PutAsync("https://api.rybbit.io/api/goals/1/123", content);
var data = await response.Content.ReadAsStringAsync();
Response
{
  "success": true,
  "goalId": 1
}

Delete Goal

DELETE /api/goals/:goalId/:site

Deletes a goal. This action cannot be undone.

Path Parameters

Prop

Type

Response

Prop

Type

Request
curl -X DELETE "https://api.rybbit.io/api/goals/1/123" \
  -H "Authorization: Bearer your_api_key_here"
Request
const response = await fetch(
  'https://api.rybbit.io/api/goals/1/123',
  {
    method: 'DELETE',
    headers: {
      'Authorization': 'Bearer your_api_key_here'
    }
  }
);

const data = await response.json();
Request
import requests

response = requests.delete(
    'https://api.rybbit.io/api/goals/1/123',
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.rybbit.io/api/goals/1/123');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
Request
require 'net/http'
require 'json'

uri = URI('https://api.rybbit.io/api/goals/1/123')
request = Net::HTTP::Delete.new(uri)
request['Authorization'] = 'Bearer your_api_key_here'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
Request
req, _ := http.NewRequest("DELETE", "https://api.rybbit.io/api/goals/1/123", nil)
req.Header.Set("Authorization", "Bearer your_api_key_here")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
Request
let client = reqwest::Client::new();
let res = client
    .delete("https://api.rybbit.io/api/goals/1/123")
    .header("Authorization", "Bearer your_api_key_here")
    .send()
    .await?;

let data: serde_json::Value = res.json().await?;
Request
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.rybbit.io/api/goals/1/123"))
    .header("Authorization", "Bearer your_api_key_here")
    .DELETE()
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

var response = await client.DeleteAsync("https://api.rybbit.io/api/goals/1/123");
var data = await response.Content.ReadAsStringAsync();
Response
{
  "success": true
}