Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScriptTagFilter behavior #76

Open
vikramshrowty opened this issue Oct 6, 2021 · 1 comment
Open

ScriptTagFilter behavior #76

vikramshrowty opened this issue Oct 6, 2021 · 1 comment

Comments

@vikramshrowty
Copy link

I can't find documentation on script-tag but from looking at the code I'm guessing that you're supposed to modify your script type to be 'text/plain' instead of 'text/javascript' and then cookieconsent will restore it to javascript if there is consent.

If so, is there a reason this is done differently from dynamic-script? Seems like it would be easier for the user if the same mechanism was used in both places?

@nklido
Copy link

nklido commented Feb 23, 2022

@vikramshrowty
I didn't find any documentation either but looking through the code basically script-tag filter
expects you to set your scripts that need to be blocked with type="text/plain" and data-consent="your-script-keyword"

for example

<script type="text/plain" data-consent="googletagmanager">
  // tag manager code here
</script>

and then at the CookieConsent config

services: {
  google_tag_manager: {
    category: 'marketing',
    type: 'script-tag',
    search: 'googletagmanager',
    language: {
    locale: {
        en: {
          name: 'Google tag manager'
        }
      }
    }
  }
}

ScriptTagFilter will run when the page loads and will enable the scripts that match the search keyword
only if the marketing cookies are accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants