> For the complete documentation index, see [llms.txt](https://api-docs.devhub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.devhub.com/content-resources/plugins.md).

# Plugins

## Plugins

The Plugins resource allows for enabling of functionality site-wide. Normally these plugins also have configurable fields that change the behavior as well has fields that take account IDs or other credentials needed for the plugin to function. It is a sub-resource of "Site".

### Supported plugins

Each plugin has specific fields. Documentation for the specific fields and example for each plugin can be found below.

| plugin\_type       |                                                                                                         |                                                                                          |
| ------------------ | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| `customtag`        | Adds custom HTML to the header, footer, or prebody (right after `<body>`) of all pages within your Site | [View example](/content-resources/plugins.md#custom-tag-plugin-customtag)                |
| `googletagmanager` | Adds the Google Tag Manager tags to your site in the correct locations within the HTML                  | [View example](/content-resources/plugins.md#google-tag-manager-plugin-googletagmanager) |

## Plugin Model

### Plugin object

A plugin object contains the following common fields

| Attribute    | Type    | Description                                                           |
| ------------ | ------- | --------------------------------------------------------------------- |
| id           | integer | Unique id of the plugin                                               |
| active       | boolean | Inactive plugins maintain configuration but do not output on the Site |
| plugin\_type | string  | Type of the plugin (required)                                         |
| site\_id     | integer | Reference id to the Site this plugin is under                         |

#### Example object:

Below is an example of a `googletagmanager` plugin which has a field unique to this plugin `account_id`. Documentation for the specific fields for each plugin can be found further [below](/content-resources/plugins.md#google-tag-manager-plugin-googletagmanager).

```javascript
{
    "active": true,
    "account_id": "PDTVXXX",
    "id": 1234,
    "plugin_type": "googletagmanager",
    "site_id": 54321
}
```

## Create a plugin

`POST /api/v2/sites/:site_id/plugins/:plugin_type/`

### Required fields

| Attribute    |
| ------------ |
| active       |
| plugin\_type |

## List plugins

List all plugins for a Site ID including active and inactive

```
GET /api/v2/sites/:site_id/plugins/
```

### Response

```javascript
{
  "meta": {
    "limit": 20,
    "next": null,
    "offset": 0,
    "previous": null,
    "total_count": 3
  },
  "objects": [
    {
      "account_id": "GA-XXXXXX",
      "active": false,
      "id": 12344,
      "plugin_type": "googleglobalsitetag",
      "site_id": 54321
    },
    {
      "account2_id": null,
      "account_id": "PDTXXXX",
      "active": true,
      "id": 12345,
      "plugin_type": "googletagmanager",
      "site_id": 54321
    },
    ...
  ]
}
```

## Get a single plugin

Fetch the Plugin detail using the `Site.id` and `Plugin.plugin_type`. This endpoint can also be used to determine if a particular plugin is already added to a Site

```
GET /api/v2/sites/:site_id/plugins/:plugin_type/
```

## Update a plugin

`PUT /api/v2/sites/:site_id/plugins/:plugin_type/`

## Delete a plugin

`DELETE /api/v2/sites/:site_id/plugins/:plugin_type/`

## Custom Tag Plugin (`customtag`)

Adds custom HTML to the header, footer, or prebody (right after `<body>`) of all pages within your Site

### Endpoint

```
GET /api/v2/sites/:site_id/plugins/customtag/
```

### Plugin object

In addition to the [common fields](/content-resources/plugins.md#plugin-object), a `customtag` plugin object contains the following fields

| Attribute         | Type   | Description                                                            |
| ----------------- | ------ | ---------------------------------------------------------------------- |
| footer\_template  | string | HTML to add to the bottom of the page before the closing `</body>` tag |
| header\_template  | string | HTML to add to the end of the `<head>` tag                             |
| prebody\_template | string | HTML to add to the start of the page right after the `<body>` tag      |

#### Example object:

```javascript
{
    "active": true,
    "footer_template": "<script src=\"...\"...></script>",
    "header_template": "<script src=\"...\"...></script>",
    "id": 1234,
    "plugin_type": "customtag",
    "prebody_template": "<script src=\"...\"...></script>",
    "site_id": 54321
}
```

## Google Global Site Tag (`googleglobalsitetag`)

Adds the Google Site Tag (i.e. `gtag`) to your site in the correct locations within the HTML.&#x20;

This plugin supports the following tracker types/account IDs

* `UA-XXXXXX` - Universal analytics (i.e. Google Analytics)&#x20;
* `G-XXXXXX` - GA4 (Google Analytics 4)

### Endpoint

```
GET /api/v2/sites/:site_id/plugins/googleglobalsitetag/
```

### Plugin object

In addition to the common fields, a `googleglobalsitetag` plugin object contains the following fields.

| Attribute    | Type   | Description              |
| ------------ | ------ | ------------------------ |
| account\_id  | string | gtag config tracking ID. |
| account2\_id | string | gtag config tracking ID. |
| account3\_id | string | gtag config tracking ID. |

## Google Tag Manager Plugin (`googletagmanager`)

Adds the Google Tag Manager tags to your site in the correct locations within the HTML

### Endpoint

```
GET /api/v2/sites/:site_id/plugins/googletagmanager/
```

### Plugin object

In addition to the [common fields](/content-resources/plugins.md#plugin-object), a `googletagmanager` plugin object contains the following fields

| Attribute   | Type   | Description                                                    |
| ----------- | ------ | -------------------------------------------------------------- |
| account\_id | string | The Google Tag Manager account ID, excluding the `GTM-` prefix |

#### Example object:

```javascript
{
    "active": true,
    "account_id": "PDTVXXX",
    "id": 1234,
    "plugin_type": "googletagmanager",
    "site_id": 54321
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://api-docs.devhub.com/content-resources/plugins.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
