> For the complete documentation index, see [llms.txt](https://cmp.docs.sirdata.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cmp.docs.sirdata.net/en/script-management/local-script-management.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cmp.docs.sirdata.net/en/script-management/local-script-management.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
