To track the effect that Chat agents have on improving sales or completing website based goals, you can set a URL-based goal (such as page views of a pricing page) that matches the URL exactly or contains a certain parameter in the URL.

Goals can be set up to capture conversions based on agent first-touch or last-touch attribution. The attribution period can be between 1 to 30 days.

Note: Accounts have a maximum limit of 5 active Goals. An error message "Goals limit exceeded" will appear if you exceed the active Goal limit.

JSON format

Goals are represented as JSON objects with the following properties:

NameTypeRead-onlyMandatoryDescription
attribution_modelstringfalsefalseDescribes the attribution model associated with the goal. One of "first_touch", "last_touch"
attribution_periodintegerfalsefalseDescribes the attribution period in days for this goal. Range between "1" to "30"
descriptionstringfalsefalseThe description of the goal
enabledintegerfalsefalseDescribes whether the goal is enabled
idintegertruefalseThe ID of the goal
namestringfalsefalseThe name of the goal
settingsobjectfalsefalseThe settings for the goal. Contains the conditions array. See Conditions

Conditions

The settings attribute contains a conditions array. The conditions array contains objects which represent individual conditions to be matched. If any single condition is met, the goal is considered to be fulfilled. Each object has the following attributes.

NameTypeRead-onlyDescription
typestringnoDescribes the type of condition. Currently supports only "url"
operatorstringnoDescribes the operator used to compare if a goal is fulfilled. One of "equals", "contains"
valuestringnoDescribes the actual value to compare if a goal is fulfilled. If operator is specified as "equals", value should start with "http://" or "https://"

Example

{  "attribution_model": "first_touch",  "attribution_period": 30,  "description": "A sample goal",  "enabled": 1,  "id": 1,  "name": "Goal 1",  "settings": {    "conditions": [      {        "operator": "equals",        "type": "url",        "value": "http://cart.com/"      },      {        "operator": "contains",        "type": "url",        "value": "cart"      }    ]  }}

List Goals

  • GET /api/v2/chat/goals

This lists all the goals for your account.

Allowed for

  • Administrator

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/chat/goals \  -v -H "Authorization: Bearer {token}"
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://subdomain.zendesk.com/api/v2/chat/goals"	method := "GET"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")
	client := &http.Client {}	res, err := client.Do(req)	if err != nil {		fmt.Println(err)		return	}	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)	if err != nil {		fmt.Println(err)		return	}	fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/goals")		.newBuilder();
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("GET", null)		.addHeader("Content-Type", "application/json")		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'GET',  url: 'https://subdomain.zendesk.com/api/v2/chat/goals',  headers: {	'Content-Type': 'application/json',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requests
url = "https://subdomain.zendesk.com/api/v2/chat/goals"headers = {	"Content-Type": "application/json",}
response = requests.request(	"GET",	url,	headers=headers)
print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/goals")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

200 OK
// Status 200 OK
[  {    "attribution_model": "first_touch",    "attribution_period": 30,    "description": "A sample goal",    "enabled": 1,    "id": 1,    "name": "Goal 1",    "settings": {      "conditions": [        {          "operator": "equals",          "type": "url",          "value": "http://cart.com/"        },        {          "operator": "contains",          "type": "url",          "value": "cart"        }      ]    }  },  {    "attribution_model": "last_touch",    "attribution_period": 15,    "description": "A sample goal",    "id": 2,    "name": "Goal 2",    "settings": {      "conditions": [        {          "operator": "equals",          "type": "url",          "value": "http://zopim.com/"        },        {          "operator": "contains",          "type": "url",          "value": "zopim"        }      ]    }  }]

Show Goal

  • GET /api/v2/chat/goals/{goal_id}

Allowed for

  • Administrator

Parameters

NameTypeInRequiredDescription
goal_idintegerPathtrueThe ID of the goal

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/chat/goals/{goal_id} \  -v -H "Authorization: Bearer {token}"
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://subdomain.zendesk.com/api/v2/chat/goals/1"	method := "GET"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")
	client := &http.Client {}	res, err := client.Do(req)	if err != nil {		fmt.Println(err)		return	}	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)	if err != nil {		fmt.Println(err)		return	}	fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/goals/1")		.newBuilder();
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("GET", null)		.addHeader("Content-Type", "application/json")		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'GET',  url: 'https://subdomain.zendesk.com/api/v2/chat/goals/1',  headers: {	'Content-Type': 'application/json',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requests
url = "https://subdomain.zendesk.com/api/v2/chat/goals/1"headers = {	"Content-Type": "application/json",}
response = requests.request(	"GET",	url,	headers=headers)
print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/goals/1")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

200 OK
// Status 200 OK
{  "attribution_model": "first_touch",  "attribution_period": 30,  "description": "A sample goal",  "enabled": 1,  "id": 1,  "name": "Goal 1",  "settings": {    "conditions": [      {        "operator": "equals",        "type": "url",        "value": "http://cart.com/"      },      {        "operator": "contains",        "type": "url",        "value": "cart"      }    ]  }}

Create Goal

  • POST /api/v2/chat/goals

Allowed for

  • Administrator

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/chat/goals \  -d '{        "name" : "Goal 3",        "description" : "A new goal",        "enabled" : 1,        "attribution_model" : "first_touch",        "attribution_period": 15,        "settings" : {          "conditions": [            {              "operator": "equals",              "type": "url",              "value": "http://mysite.com/"            }          ]        }      }' \  -v -H "Authorization: Bearer {token}" \  -H "Content-Type: application/json" -X POST
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://subdomain.zendesk.com/api/v2/chat/goals"	method := "POST"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")
	client := &http.Client {}	res, err := client.Do(req)	if err != nil {		fmt.Println(err)		return	}	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)	if err != nil {		fmt.Println(err)		return	}	fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/goals")		.newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),		"""""");
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("POST", body)		.addHeader("Content-Type", "application/json")		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'POST',  url: 'https://subdomain.zendesk.com/api/v2/chat/goals',  headers: {	'Content-Type': 'application/json',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requests
url = "https://subdomain.zendesk.com/api/v2/chat/goals"headers = {	"Content-Type": "application/json",}
response = requests.request(	"POST",	url,	headers=headers)
print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/goals")request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

201 Created
// Status 201 Created
{  "attribution_model": "first_touch",  "attribution_period": 30,  "description": "A sample goal",  "enabled": 1,  "id": 1,  "name": "Goal 1",  "settings": {    "conditions": [      {        "operator": "equals",        "type": "url",        "value": "http://cart.com/"      },      {        "operator": "contains",        "type": "url",        "value": "cart"      }    ]  }}

Update Goal

  • PUT /api/v2/chat/goals/{goal_id}

Allowed for

  • Administrator

Parameters

NameTypeInRequiredDescription
goal_idintegerPathtrueThe ID of the goal

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/chat/goals/3 \  -d '{"name": "Good goal"}' \  -v -H "Authorization: Bearer {token}" \  -H "Content-Type: application/json" -X PUT
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://subdomain.zendesk.com/api/v2/chat/goals/1"	method := "PUT"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")
	client := &http.Client {}	res, err := client.Do(req)	if err != nil {		fmt.Println(err)		return	}	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)	if err != nil {		fmt.Println(err)		return	}	fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/goals/1")		.newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),		"""""");
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("PUT", body)		.addHeader("Content-Type", "application/json")		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'PUT',  url: 'https://subdomain.zendesk.com/api/v2/chat/goals/1',  headers: {	'Content-Type': 'application/json',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requests
url = "https://subdomain.zendesk.com/api/v2/chat/goals/1"headers = {	"Content-Type": "application/json",}
response = requests.request(	"PUT",	url,	headers=headers)
print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/goals/1")request = Net::HTTP::Put.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

200 OK
// Status 200 OK
{  "attribution_model": "first_touch",  "attribution_period": 15,  "description": "A mew goal",  "enabled": 1,  "id": 3,  "name": "Good goal",  "settings": {    "conditions": [      {        "operator": "equals",        "type": "url",        "value": "http://mysite.com/"      }    ]  }}

Delete Goal

  • DELETE /api/v2/chat/goals/{goal_id}

Allowed for

  • Administrator

Parameters

NameTypeInRequiredDescription
goal_idintegerPathtrueThe ID of the goal

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/chat/goals/3 \  -v -H "Authorization: Bearer {token}" -X DELETE
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://subdomain.zendesk.com/api/v2/chat/goals/1"	method := "DELETE"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")
	client := &http.Client {}	res, err := client.Do(req)	if err != nil {		fmt.Println(err)		return	}	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)	if err != nil {		fmt.Println(err)		return	}	fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://subdomain.zendesk.com/api/v2/chat/goals/1")		.newBuilder();
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("DELETE", null)		.addHeader("Content-Type", "application/json")		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'DELETE',  url: 'https://subdomain.zendesk.com/api/v2/chat/goals/1',  headers: {	'Content-Type': 'application/json',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requests
url = "https://subdomain.zendesk.com/api/v2/chat/goals/1"headers = {	"Content-Type": "application/json",}
response = requests.request(	"DELETE",	url,	headers=headers)
print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/goals/1")request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

204 No Content
// Status 204 No Content
null