Local script Management
The script management logic described on the previous pages can be used for JavaScript functions. You just have to wrap the latter to call it in the same way as a remote script.
Example 1
<script>
console.log("demo");
</script>
becomes, when inserted in main source code:
<script>
function myScript() {
console.log("demo");
}
</script>
<script data-cmp-src="myScript"></script>
or via a Tag Manager:
<script>
function myScript() {
console.log("demo");
}
</script>
<script data-cmp-src="myScript"></script>
<script>try{Sddan.cmp.triggerTM();}catch(e){}</script>
Example 2
<script>
(function() {
console.log("demo");
})();
</script>
becomes, when inserted in the main source code:
<script>
function myScript() {
(function() {
console.log("demo");
})();
}
</script>
<script data-cmp-src="myScript"></script>
or via a Tag Manager:
<script>
function myScript() {
(function() {
console.log("demo");
})();
}
</script>
<script data-cmp-src="myScript"></script>
<script>try{Sddan.cmp.triggerTM();}catch(e){}</script>
All the advanced features described on the next page are available when managing these scripts in your main page or via the Tag Manager.
Dernière mise à jour
Cet article vous a-t-il été utile ?