> For the complete documentation index, see [llms.txt](https://doc.dastra.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.dastra.eu/en/features/gerer-le-consentement-aux-cookies/integration-technique/blocage-des-cookies.md).

# Blocking cookies

A COMPLETER

To effectively block cookies, there are several possible methods: blocking a snippet, custom javascript or Google Tag Manage.

{% hint style="info" %}
Go to the service management interface, when editing a service, the simplified name (slug) of the service appears below the cookie name.
{% endhint %}

## Blocking a code snippet in the page

This method allows you to completely disable a code snippet for tracking the page.

To do this, replace the following code snippet in the html code of your page:

```ssml
<script >
  alert("hello, I'm a tracking javascript tag");
</script>
```

By:

```ssml
<script data-consent="{your-service-slug}" type="dastra/script">
   alert("hello, I'm a tracking javascript tag");
</script>
```

Replace `{your-service-slug}` with the service slug configured in your widget (visible in the service editing interface, below the cookie name).

***

## FAQ

**Can I block a script by category instead of by service? (e.g. `data-consent="analytics"`)**

No. The `data-consent` attribute expects a **service slug**, not a category slug. Writing `<script data-consent="analytics" type="dastra/script">` to block all services in a category in one directive is not supported.

The reason: a user may accept some services within a category while refusing others in the same category. The widget manages consent at the service level, not the category level.

If you want to conditionally load a script based on whether an entire category has been accepted, use the programmatic API instead:

```javascript
window.addEventListener('dastra:consents:updated', function() {
  if (window.dastra.cookieConsent.consent.getPurposeConsent('Analytical')) {
    // load your analytics scripts here
  }
});
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.dastra.eu/en/features/gerer-le-consentement-aux-cookies/integration-technique/blocage-des-cookies.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.
