Add a Tag to a container
Add a Tag to a container
POST
https://api.ocamba.com/v1/hood/containers/{container_id}/tags
Add a Tag to a containerRate limits:
- Burst: 10/s
- Steady: 150/m
Path parameters
parametersRequest schema
bodyResponse schemas
›
201
application/json
›
400
application/json
›
500
application/json
curl -X POST \
"https://api.ocamba.com/v1/hood/containers/{container_id}/tags" \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "Custom tag",
"status": "active",
"type": "custom-code",
"settings": {
"js_code": "<script>\n const myDiv = document.createElement('\''div'\'');\n myDiv.id = '\''DIV_LOADED'\'';\n myDiv.textContent = '\''This is a div'\'';\n myDiv.style.backgroundColor = '\''red'\'';\n myDiv.style.color = '\''white'\'';\n myDiv.style.padding = '\''10px'\'';\n myDiv.style.margin = '\''10px 0'\'';\n document.body.appendChild(myDiv);\n </script>"
},
"target": {
"element": "head",
"action": "append"
}
}'const url = 'https://api.ocamba.com/v1/hood/containers/{container_id}/tags';
const options = {
method: 'POST',
headers: {
Authorization: "Bearer {TOKEN}",
'Content-Type': "application/json"
},
body: JSON.stringify(
{
"name": "Custom tag",
"status": "active",
"type": "custom-code",
"settings": {
"js_code": "<script>\n const myDiv = document.createElement('div');\n myDiv.id = 'DIV_LOADED';\n myDiv.textContent = 'This is a div';\n myDiv.style.backgroundColor = 'red';\n myDiv.style.color = 'white';\n myDiv.style.padding = '10px';\n myDiv.style.margin = '10px 0';\n document.body.appendChild(myDiv);\n </script>"
},
"target": {
"element": "head",
"action": "append"
}
}
)
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}$ch = curl_init("https://api.ocamba.com/v1/hood/containers/{container_id}/tags");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {TOKEN}",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
[
"name" => "Custom tag",
"status" => "active",
"type" => "custom-code",
"settings" => [
"js_code" => "<script>\n const myDiv = document.createElement('div');\n myDiv.id = 'DIV_LOADED';\n myDiv.textContent = 'This is a div';\n myDiv.style.backgroundColor = 'red';\n myDiv.style.color = 'white';\n myDiv.style.padding = '10px';\n myDiv.style.margin = '10px 0';\n document.body.appendChild(myDiv);\n </script>"
],
"target" => [
"element" => "head",
"action" => "append"
]
]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);curl -X POST \
"https://api.ocamba.com/v1/hood/containers/{container_id}/tags" \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "Test Custom Tag",
"status": "active",
"type": "custom-code",
"triggers": {
"consent_initiation": false,
"page_view": false,
"visibility": true,
"scroll_depth": {
"horizontal": {
"percentage": 100
},
"enable_on": "window-load"
},
"form_submission": true,
"exit_intent": false,
"timer": 60000,
"custom_event": "onload",
"require_all_triggers": false,
"delay": 0
},
"filters": [
{
"variable": "5647",
"op": "not-starts-with",
"value": "Some-value",
"filters": [
{
"variable": "5645",
"op": "eq",
"value": "Some-value"
}
]
}
],
"target": "head",
"settings": {
"js_code": "return myFunc()"
},
"position": 7,
"deleted": 0
}'const url = 'https://api.ocamba.com/v1/hood/containers/{container_id}/tags';
const options = {
method: 'POST',
headers: {
Authorization: "Bearer {TOKEN}",
'Content-Type': "application/json"
},
body: JSON.stringify(
{
"name": "Test Custom Tag",
"status": "active",
"type": "custom-code",
"triggers": {
"consent_initiation": false,
"page_view": false,
"visibility": true,
"scroll_depth": {
"horizontal": {
"percentage": 100
},
"enable_on": "window-load"
},
"form_submission": true,
"exit_intent": false,
"timer": 60000,
"custom_event": "onload",
"require_all_triggers": false,
"delay": 0
},
"filters": [
{
"variable": "5647",
"op": "not-starts-with",
"value": "Some-value",
"filters": [
{
"variable": "5645",
"op": "eq",
"value": "Some-value"
}
]
}
],
"target": "head",
"settings": {
"js_code": "return myFunc()"
},
"position": 7,
"deleted": 0
}
)
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}$ch = curl_init("https://api.ocamba.com/v1/hood/containers/{container_id}/tags");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {TOKEN}",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
[
"name" => "Test Custom Tag",
"status" => "active",
"type" => "custom-code",
"triggers" => [
"consent_initiation" => false,
"page_view" => false,
"visibility" => true,
"scroll_depth" => [
"horizontal" => [
"percentage" => 100
],
"enable_on" => "window-load"
],
"form_submission" => true,
"exit_intent" => false,
"timer" => 60000,
"custom_event" => "onload",
"require_all_triggers" => false,
"delay" => 0
],
"filters" => [
[
"variable" => "5647",
"op" => "not-starts-with",
"value" => "Some-value",
"filters" => [
[
"variable" => "5645",
"op" => "eq",
"value" => "Some-value"
]
]
]
],
"target" => "head",
"settings" => [
"js_code" => "return myFunc()"
],
"position" => 7,
"deleted" => 0
]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);curl -X POST \
"https://api.ocamba.com/v1/hood/containers/{container_id}/tags" \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "Test Google Tag",
"status": "active",
"type": "google-analytics",
"settings": {
"google_tag_id": "G-123414212"
},
"target": {
"element": "body",
"action": "prepend"
},
"filters": [
{
"variable": "66",
"op": "eq",
"value": "10"
}
]
}'const url = 'https://api.ocamba.com/v1/hood/containers/{container_id}/tags';
const options = {
method: 'POST',
headers: {
Authorization: "Bearer {TOKEN}",
'Content-Type': "application/json"
},
body: JSON.stringify(
{
"name": "Test Google Tag",
"status": "active",
"type": "google-analytics",
"settings": {
"google_tag_id": "G-123414212"
},
"target": {
"element": "body",
"action": "prepend"
},
"filters": [
{
"variable": "66",
"op": "eq",
"value": "10"
}
]
}
)
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}$ch = curl_init("https://api.ocamba.com/v1/hood/containers/{container_id}/tags");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {TOKEN}",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
[
"name" => "Test Google Tag",
"status" => "active",
"type" => "google-analytics",
"settings" => [
"google_tag_id" => "G-123414212"
],
"target" => [
"element" => "body",
"action" => "prepend"
],
"filters" => [
[
"variable" => "66",
"op" => "eq",
"value" => "10"
]
]
]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);Responses
201 Created
{
"id": "1004057",
"company_id": "6197120",
"container_id": "59389",
"status": "active",
"type": "custom-code",
"name": "Custom tag",
"target": {
"element": "head",
"action": "append"
},
"settings": {
"js_code": "<script>\n const myDiv = document.createElement('div');\n myDiv.id = 'DIV_LOADED';\n myDiv.textContent = 'This is a div';\n myDiv.style.backgroundColor = 'red';\n myDiv.style.color = 'white';\n myDiv.style.padding = '10px';\n myDiv.style.margin = '10px 0';\n document.body.appendChild(myDiv);\n </script>"
},
"position": 1,
"deleted": 0
}
400 Bad Request
{
"code": 400,
"title": "Bad request.",
"message": "The request body is not valid.",
"trace_id": "99a84211-f73d-4ff8-acdf-eb3e06bb9d62"
}
500 Internal Server Error
{
"code": 500,
"title": "Internal server error.",
"trace_id": "99a84211-f73d-4ff8-acdf-eb3e06bb9d62"
}
Responses