# Remote Tags Management with a Tag Manager

The Tag Management method described in the previous page can be used via a Tag Manager and the method remains the same except that it is necessary to manually trigger the processing of the stack via the following dedicated function.

```markup
<script>try{Sddan.cmp.triggerTM();}catch(e){}</script>
```

{% hint style="danger" %}
As this functionality is integrated within the CMP, it will only work if the CMP is loaded on the page.
{% endhint %}

{% hint style="info" %}
This method allows a great technical simplification of the tag management. However, it is important to keep in mind that legal expertise is necessary to figure out how to apply it by yourself.

\
For each tag/beacon, you must:

* Evaluate the possible presence of non-exempted trackers (cookies, indexdb, local storage, etc.) (ePrivacy Directive)
* Evaluate the processing of personal data and, if applicable, the purposes pursued by your partners and their respective legal bases (GDPR)
* Evaluate if a tag/beacon is automatically supported by your partners thanks to the CMP APIs (e.g.: Google and Microsoft Bing's "Consent Mode")

Don't hesitate to ask our team to set up these packaging for you:&#x20;

<https://cmp.docs.sirdata.net/v/en/script-management/tag-conditioning-service>
{% endhint %}

### Method  <a href="#configuration" id="configuration"></a>

{% hint style="info" %}
Proceed as described on the previous page but add the above function:

* Either for each tag you want to condition
* Either once as the last script loaded by the Tag Manager
  {% endhint %}

```markup
<script src="https://www.example.com/script.js"></script>
```

becomes in the Tag Manager:

```markup
<script data-cmp-src="https://www.example.com/script.js"></script>
<script>try{Sddan.cmp.triggerTM();}catch(e){}</script>
```

If the tag is inserted in JavaScript :

```markup
<script>
(function() {
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.src = 'https://www.example.com';
    var _head = document.head || document.getElementsByTagName("head")[0];
    _head.appendChild(s);
})();
</script>
```

becomes in the Tag Manager:

```markup
<script>
(function() {
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.setAttribute('data-cmp-src','https://www.example.com');
    var _head = document.head || document.getElementsByTagName("head")[0];
    _head.appendChild(s);
})();
</script
```

{% hint style="warning" %}
All advanced features ar available for both tags inserted directly in the source code and via a Tag Manager.
{% endhint %}

## Specific case for Google Tag Manager

It is possible to set each tag as explained above via the `data-cmp-src` attribute and to trigger the `Sddan.cmp.triggerTM()` function only once as the last script with a lower priority.

{% hint style="danger" %}
Careful : it is MANDATORY, for each tag, to check the "Support document.write" box.
{% endhint %}

![](https://1869615683-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MUspPnkTFMlMDdGxvAb%2F-MZy-bVyRGuk0eGAHGFl%2F-MZy015FzzP4qzqNnka9%2Fimage.png?alt=media\&token=15da4ef5-8fea-40a4-9abb-b86f7d2bb70e)

{% tabs %}
{% tab title="Tag 1" %}

```markup
<script data-cmp-src="https://www.example2.com/script.js"></script>
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Tag 2" %}

```markup
<script data-cmp-src="https://www.example3.com/script.js"></script>
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Tag X" %}

```markup
<script data-cmp-src="https://www.exampleX.com/script.js"></script>
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Last tag" %}

```markup
<script>try{Sddan.cmp.triggerTM();}catch(e){}</script>
```

{% endtab %}
{% endtabs %}

This newly added last tag should bet set like that in GTM and triggered once per page:

![-10 Tag firing priority](https://1869615683-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MUspPnkTFMlMDdGxvAb%2F-MXlWbrA_Zpv9vD27KBK%2F-MXlYPJERg6C8ccSmkz2%2Fimage.png?alt=media\&token=b093fe6d-9410-4c22-b2c9-c2f64c64f18b)
