# 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.

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

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

## Example 1

```markup
<script>
    console.log("demo");
</script>
```

becomes, when inserted in main source code:

```markup
<script>
function myScript() {
    console.log("demo");
}
</script>
<script data-cmp-src="myScript"></script>
```

or via a Tag Manager:

```markup
<script>
function myScript() {
    console.log("demo");
}
</script>
<script data-cmp-src="myScript"></script>
<script>try{Sddan.cmp.triggerTM();}catch(e){}</script>
```

## Example 2

```markup
<script>
(function() {
    console.log("demo");
})();
</script>
```

becomes, when inserted in the main source code:

```markup
<script>
function myScript() {
    (function() {
        console.log("demo");
    })();
}
</script>
<script data-cmp-src="myScript"></script>
```

or via a Tag Manager:

```markup
<script>
    function myScript() {
        (function() {
            console.log("demo");
        })();
    }
</script>
<script data-cmp-src="myScript"></script>
<script>try{Sddan.cmp.triggerTM();}catch(e){}</script>
```

{% hint style="warning" %}
All the advanced features described on the next page are available when managing these scripts in your main page or via the Tag Manager.
{% endhint %}


---

# 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://cmp.docs.sirdata.net/en/script-management/local-script-management.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.
