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.

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

As this functionality is integrated within the CMP, it will only work if the CMP is loaded on the page.

Method

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

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

becomes in the Tag Manager:

<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 :

<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:

<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

All advanced features ar available for both tags inserted directly in the source code and via a Tag Manager.

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.

Careful : it is MANDATORY, for each tag, to check the "Support document.write" box.

Tag 1
Tag 1
<script data-cmp-src="https://www.example2.com/script.js"></script>
Tag 2
Tag 2
<script data-cmp-src="https://www.example3.com/script.js"></script>
Tag X
Tag X
<script data-cmp-src="https://www.exampleX.com/script.js"></script>
Last tag
Last tag
<script>try{Sddan.cmp.triggerTM();}catch(e){}</script>

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

-10 Tag firing priority