# Ein neues Tag für einen neuen Controller hinzufügen

Es muss eine Tag-Klasse erstellt werden, welche von `\norisk\nrGoogleTagManager\Core\Tag\nrGTM_Tag` erbt und die `public method getTag` implementiert

{% code title="example.php //via Content Seite" %}

```php
class ContentTag extends \norisk\nrGoogleTagManager\Core\Tag\nrGTM_Tag
{
  public function getTag(): array
  {
    $parent = parent::getTag();
    $contentTag = $this->getContentTag();

    return $this->output($parent, $contentTag);
  }

  protected function getContentTag(): array
  {
    $contentId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxcid');
    $loadId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxloadid');

    $content = oxNew(\OxidEsales\Eshop\Application\Model\Content::class);
    $loaded = false;

    if ($loadId) {
      $loaded = $content->loadByIdent($loadId);
    } elseif ($contentId) {
      $loaded = $content->load($contentId);
    }
    if (!$loaded) {
      return [];
    }

    return [
      'title' => $content->getFieldData('oxtitle'),
      'id' => $content->getId(),
    ];
  }
}
```

{% endcode %}

Die Klasse `ViewConfig` muss erweitert werden, um den neuen Controller und die Tag-Klasse zu `nrGTM_ViewConfig::$gtmClassMap` hinzuzufügen

{% code title="example2.php" %}

```php
class nrExt_ViewConfig extends nrExt_ViewConfig_parent
{
  public function __construct()
  {
    parent::__construct();

    $this->gtmClassMap['content'] = ContentTag::class;
  }
}
```

{% endcode %}


---

# Agent Instructions: 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:

```
GET https://docs.norisk.group/oxid/noriskmodules/nrgtm/extension-guide/ein-neues-tag-fuer-einen-neuen-controller-hinzufuegen.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
