Add a Tag to a container


                https://api.ocamba.com/v1/hood/containers/{container_id}/tags
            

Add a Tag to a container

Rate limits:

Burst: 10/s
Steady: 150/m


Name
Description
container_idstringrequired
Unique Container identifier.


Example: 12345


Name
Description
filters[ tag-filter ]

Tag filter
Name
Description
filters[ object ]
Array of filter objects. This object is the same as the tag filter object(including this field).

opstring
Filter operator.

Possible values: eq | neq | lt | lte | gt | gte | is-set | is-not-set | is-empty | is-not-empty | is-true | is-false | contains | not-contains | starts-with | not-starts-with | ends-with | not-ends-with | match-css | not-match-css | match-regex | not-match-regex | match-regex-no-case | not-match-regex-no-case

valuestring
Filter value. Minimum 1, maximum 1000 characters.


Example: Some-value

variablestring
Variable to filter. You can add either system or user-defined variables, and each variable must have a valid id.


Example: campaign

google_tag_idstring
Google tag id, only available for google-analytics type tags. Required if type of tag is google-analytics.


Example: GT-1NJSO23B

js_codestringrequired
Js code for custom-code or google-analytics type tag. Maximum length 102400 characters. For google-analytics type tags, it is the google tag snippet code and not settable by user.


Example: var modal = document.createElement('div'); modal.style.position = 'fixed'; modal.style.top = '50%'; modal.style.left = '50%'; modal.style.transform = 'translate(-50%, -50%)'; modal.style.width = '300px'; modal.style.height = '150px'; modal.style.backgroundColor = 'white'; modal.style.border = '2px solid #000'; modal.style.zIndex = '9999'; modal.style.padding = '24px'; modal.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)'; modal.style.textAlign = 'center'; modal.style.display = 'none'; // Hidden by default var modalMessage = document.createElement('p'); modalMessage.innerText = 'This is a modal created via Tag Manager!'; modal.appendChild(modalMessage); var closeButton = document.createElement('button'); closeButton.innerText = 'Close'; closeButton.style.marginTop = '10px'; closeButton.onclick = function() { modal.style.display = 'none'; modal.appendChild(closeButton);

namestringrequired
Name of the Container Tag. Must be unique per container.


Example: Container Tag Example

targetstringrequired
Describes the element into which the tag will be inserted. Can be head, body, before-body-end, before-head-end or a custom css selector. Maximum 100 characters


Example: head

triggersobjectrequired

Name
Description
consent_initiationboolean
Describes if consent initiation trigger is turned on.

element_visibility[ tag-element-visibility ]
Allows to set tag to fire when certain elements of a page are visible.
element-visibility
Name
Description
min_on_screen_timenumber (integer)
Minimum on screen time of the element for trigger to fire in milliseconds. Minimum value 100, maximum value 30000.


Example: 200

min_percent_visiblenumber (decimal)
Minimum percentage of element visible to fire the trigger. Minimum value 1, maximum value 100.


Example: 2.22

observe_dom_changesboolean



Example: true

selectorstring
Identifies the correct element to select. Accepts both css selector name and element id. Maximum length 50 characters.


Example: .class

when_to_firestring
Describes when the tag is fired.


Example: once-per-page

Possible values: once-per-page | once-per-element | every-time

form_submissionobject

Name
Description
check_validationboolean
Describes if trigger should check if the form meets validation rules before firing.

wait_for_tagsnumber (integer)
Describes how long the trigger will wait for additional tags before firing in milliseconds. Minimum value 100, maximum 30000.


Example: 1200

page_viewboolean
Describes if page view trigger is turned on.

scroll_depthobject

Name
Description
enable_onstring
Describes when the trigger will be loaded.


Example: window-load

Possible values: container-load | window-load | dom-ready

horizontalscroll-options
Allows the user to finely tune the conditions for firing a tag based on user horizontal scroll behaviour.
Scroll options
Name
Description
percentagenumber (integer)
Describes how far a user needs to scroll for tag to fire in pixels. Minimum 1, maximum 100.


Example: 75

pixelsnumber (integer)
Describes how far a user needs to scroll for tag to fire in pixels. Minimum 1, maximum 3840.


Example: 1223

Allows the user to finely tune the conditions for firing a tag based on user horizontal scroll behaviour.

typestringrequired
Describes the type of tag.


Example: custom-code

Possible values: custom-code | google-analytics

201 - Created
Arrow
Name
Description
filters[ tag-filter ]

Tag filter
Name
Description
filters[ object ]
Array of filter objects. This object is the same as the tag filter object(including this field).

opstring
Filter operator.

Possible values: eq | neq | lt | lte | gt | gte | is-set | is-not-set | is-empty | is-not-empty | is-true | is-false | contains | not-contains | starts-with | not-starts-with | ends-with | not-ends-with | match-css | not-match-css | match-regex | not-match-regex | match-regex-no-case | not-match-regex-no-case

valuestring
Filter value. Minimum 1, maximum 1000 characters.


Example: Some-value

variablestring
Variable to filter. You can add either system or user-defined variables, and each variable must have a valid id.


Example: campaign

google_tag_idstring
Google tag id, only available for google-analytics type tags. Required if type of tag is google-analytics.


Example: GT-1NJSO23B

js_codestringrequired
Js code for custom-code or google-analytics type tag. Maximum length 102400 characters. For google-analytics type tags, it is the google tag snippet code and not settable by user.


Example: var modal = document.createElement('div'); modal.style.position = 'fixed'; modal.style.top = '50%'; modal.style.left = '50%'; modal.style.transform = 'translate(-50%, -50%)'; modal.style.width = '300px'; modal.style.height = '150px'; modal.style.backgroundColor = 'white'; modal.style.border = '2px solid #000'; modal.style.zIndex = '9999'; modal.style.padding = '24px'; modal.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)'; modal.style.textAlign = 'center'; modal.style.display = 'none'; // Hidden by default var modalMessage = document.createElement('p'); modalMessage.innerText = 'This is a modal created via Tag Manager!'; modal.appendChild(modalMessage); var closeButton = document.createElement('button'); closeButton.innerText = 'Close'; closeButton.style.marginTop = '10px'; closeButton.onclick = function() { modal.style.display = 'none'; modal.appendChild(closeButton);

namestringrequired
Name of the Container Tag. Must be unique per container.


Example: Container Tag Example

targetstringrequired
Describes the element into which the tag will be inserted. Can be head, body, before-body-end, before-head-end or a custom css selector. Maximum 100 characters


Example: head

triggersobjectrequired

Name
Description
consent_initiationboolean
Describes if consent initiation trigger is turned on.

element_visibility[ tag-element-visibility ]
Allows to set tag to fire when certain elements of a page are visible.
element-visibility
Name
Description
min_on_screen_timenumber (integer)
Minimum on screen time of the element for trigger to fire in milliseconds. Minimum value 100, maximum value 30000.


Example: 200

min_percent_visiblenumber (decimal)
Minimum percentage of element visible to fire the trigger. Minimum value 1, maximum value 100.


Example: 2.22

observe_dom_changesboolean



Example: true

selectorstring
Identifies the correct element to select. Accepts both css selector name and element id. Maximum length 50 characters.


Example: .class

when_to_firestring
Describes when the tag is fired.


Example: once-per-page

Possible values: once-per-page | once-per-element | every-time

form_submissionobject

Name
Description
check_validationboolean
Describes if trigger should check if the form meets validation rules before firing.

wait_for_tagsnumber (integer)
Describes how long the trigger will wait for additional tags before firing in milliseconds. Minimum value 100, maximum 30000.


Example: 1200

page_viewboolean
Describes if page view trigger is turned on.

scroll_depthobject

Name
Description
enable_onstring
Describes when the trigger will be loaded.


Example: window-load

Possible values: container-load | window-load | dom-ready

horizontalscroll-options
Allows the user to finely tune the conditions for firing a tag based on user horizontal scroll behaviour.
Scroll options
Name
Description
percentagenumber (integer)
Describes how far a user needs to scroll for tag to fire in pixels. Minimum 1, maximum 100.


Example: 75

pixelsnumber (integer)
Describes how far a user needs to scroll for tag to fire in pixels. Minimum 1, maximum 3840.


Example: 1223

Allows the user to finely tune the conditions for firing a tag based on user horizontal scroll behaviour.

typestringrequired
Describes the type of tag.


Example: custom-code

Possible values: custom-code | google-analytics

400 - Bad Request
Arrow
Name
Description
codeinteger
Http response status code.


Example: 400

messagestring
The human readable message that describes how to deal with error.


Example: The request body is not valid.

titlestring
The error title.


Example: Bad request.

trace_idstring
Error trace id.


Example: 99a84211-f73d-4ff8-acdf-eb3e06bb9d62

500 - Internal Server Error
Arrow
Name
Description
codeinteger
Http response status code.


Example: 500

titlestring
The error title.


Example: Internal server error.

trace_idstring
Error trace id.


Example: 99a84211-f73d-4ff8-acdf-eb3e06bb9d62
request Arrow
{
  "name":"tag1",
  "type": "custom-code",
  "js_code": "var modal = document.createElement('div');\nmodal.style.position = 'fixed';\nmodal.style.top = '50%';\nmodal.style.left = '50%';\nmodal.style.transform = 'translate(-50%, -50%)';\nmodal.style.width = '300px';\nmodal.style.height = '150px';\nmodal.style.backgroundColor = 'white';\nmodal.style.border = '2px solid #000';\nmodal.style.zIndex = '9999';\nmodal.style.padding = '20px';\nmodal.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)';\nmodal.style.textAlign = 'center';\nmodal.style.display = 'none'; // Hidden by default\n\nvar modalMessage = document.createElement('p');\nmodalMessage.innerText = 'This is a modal created via Tag Manager!';\nmodal.appendChild(modalMessage);\n\nvar closeButton = document.createElement('button');\ncloseButton.innerText = 'Close';\ncloseButton.style.marginTop = '10px';\ncloseButton.onclick = function() {\nmodal.style.display = 'none';\n\nmodal.appendChild(closeButton);\n",
  "triggers": {
    "element_visibility": [
      {
        "selector": ".class",
        "when_to_fire": "once-per-page",
        "min_percent_visible": 50,
        "min_on_screen_time": 100,
        "observe_dom_changes": true
      }
    ],
    "scroll_depth": {
      "enable_on": "window-load"
    },
    "form_submission": {
      "wait_for_tags": 1200
    }
  },
  "filters": [
    {
      "variable": "campaign",
      "op":"not-starts-with",
      "value": "Some-value",
      "filters": [
        {
          "variable": "campaign",
          "op":"eq",
          "value": "Some-value"
        }
      ]
    }
  ],
  "target": "head"
}
201 Arrow
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name":"tag1",
  "type": "custom-code",
  "js_code": "var modal = document.createElement('div');\nmodal.style.position = 'fixed';\nmodal.style.top = '50%';\nmodal.style.left = '50%';\nmodal.style.transform = 'translate(-50%, -50%)';\nmodal.style.width = '300px';\nmodal.style.height = '150px';\nmodal.style.backgroundColor = 'white';\nmodal.style.border = '2px solid #000';\nmodal.style.zIndex = '9999';\nmodal.style.padding = '20px';\nmodal.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)';\nmodal.style.textAlign = 'center';\nmodal.style.display = 'none'; // Hidden by default\n\nvar modalMessage = document.createElement('p');\nmodalMessage.innerText = 'This is a modal created via Tag Manager!';\nmodal.appendChild(modalMessage);\n\nvar closeButton = document.createElement('button');\ncloseButton.innerText = 'Close';\ncloseButton.style.marginTop = '10px';\ncloseButton.onclick = function() {\nmodal.style.display = 'none';\n\nmodal.appendChild(closeButton);\n",
  "triggers": {
    "element_visibility": [
      {
        "selector": ".class",
        "when_to_fire": "once-per-page",
        "min_percent_visible": 50,
        "min_on_screen_time": 200,
        "observe_dom_changes": true
      }
    ],
    "scroll_depth": {
      "enable_on": "window-load"
    },
    "form_submission": {
      "wait_for_tags": 1200
    }
  },
  "filters": [
    {
      "variable": "campaign",
      "op":"not-starts-with",
      "value": "Some-value",
      "filters": [
        {
          "variable": "campaign",
          "op":"eq",
          "value": "Some-value"
        }
      ]
    }
  ],
  "target": "head"
}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Container Tag Example",
  "type": "custom-code",
  "google_tag_id": "GT-1NJSO23B",
  "js_code": "var modal = document.createElement('div');\nmodal.style.position = 'fixed';\nmodal.style.top = '50%';\nmodal.style.left = '50%';\nmodal.style.transform = 'translate(-50%, -50%)';\nmodal.style.width = '300px';\nmodal.style.height = '150px';\nmodal.style.backgroundColor = 'white';\nmodal.style.border = '2px solid #000';\nmodal.style.zIndex = '9999';\nmodal.style.padding = '24px';\nmodal.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)';\nmodal.style.textAlign = 'center';\nmodal.style.display = 'none'; // Hidden by default\n\nvar modalMessage = document.createElement('p');\nmodalMessage.innerText = 'This is a modal created via Tag Manager!';\nmodal.appendChild(modalMessage);\n\nvar closeButton = document.createElement('button');\ncloseButton.innerText = 'Close';\ncloseButton.style.marginTop = '10px';\ncloseButton.onclick = function() {\nmodal.style.display = 'none';\n\nmodal.appendChild(closeButton);\n",
  "triggers": {
    "element_visibility": [
      {
        "selector": ".class",
        "when_to_fire": "once-per-page",
        "min_percent_visible": 2.22,
        "min_on_screen_time": 200,
        "observe_dom_changes": true
      }
    ],
    "scroll_depth": {
      "horizontal": {
        "percentage": 75,
        "pixels": 1223
      },
      "vertical": {
        "percentage": 75,
        "pixels": 1223
      },
      "enable_on": "window-load"
    },
    "form_submission": {
      "wait_for_tags": 1200
    }
  },
  "filters": [
    {
      "variable": "campaign",
      "value": "Some-value",
      "filters": [
        {
          "variable": "campaign",
          "value": "Some-value"
        }
      ]
    }
  ],
  "target": "head",
  "create_time": "2021-10-29 12:47:00",
  "update_time": "2021-10-30 14:27:26"
}
{
  "code": 400,
  "title": "Bad request.",
  "message": "The request body is not valid.",
  "trace_id": "99a84211-f73d-4ff8-acdf-eb3e06bb9d62"
}
{
  "code": 500,
  "title": "Internal server error.",
  "trace_id": "99a84211-f73d-4ff8-acdf-eb3e06bb9d62"
}