I´d like to disable a local JS. I´ve tried some variations, but only one works. Does anybody have an idea please?
I use: Opt-in with categories.
Machine readable name of category is: analyse_marketing
Path to JS:
sites/default/files/google_tag/google_tagmanager/google_tag.script.js
Do not work:
analyse_marketing:public://google_tag/google_tagmanager/google_tag.script.js
analyse_marketing:sites/default/files/google_tag/google_tagmanager/google_tag.script.js
analyse_marketing:/sites/default/files/google_tag/google_tagmanager/google_tag.script.js
analyse_marketing:https://www.mydomain.com/sites/default/files/google_tag/google_tagmanage...
Work:
http://www.mydomain.com/sites/default/files/google_tag/google_tagmanager...
Comments
Comment #2
beg76 commentedIt also do not prevent loading other external scripts like Smartlook or Google TagManager.
If i put
in Disable Javascript field, it still loads the JS without giving consent.
Comment #3
svenryen commented@beg76, which modules provide the scripts that you link to in your last comment?
Comment #4
svenryen commentedI take it this is the module https://www.drupal.org/project/smartlook_tracking. I'll see if I can install it and help you out.
Comment #5
johnzzonWe're using the GoogleTagManager module (https://www.drupal.org/project/google_tag) and it looks like @beg76 uses the same (at least the path to the script is the same)
This module uses hook_page_attachments() to add the script in the head, so the script is not available in hook_js_alter() from what I can tell.
Added related issue of that module.
Comment #6
svenryen commentedFWIW, I checked, and I was able to exclude and load the script using:
analyse_marketing:/sites/default/files/google_tag/google_tagmanager/google_tag.script.jsThere's a bug though, which causes scripts to be appended and load even though the category hasn't been accepted. (Edit: The bug was caused by having a category with machine name 0).
Comment #7
svenryen commentedAnd I just realised this bug was reported in 7.x and not 8.x. I'll have a look and see what can be done to improve this feature in 7.x.
Comment #8
svenryen commentedI was able to exclude the script in D7 as well.
The setting to use is:
analyse_marketing:https://www.mydomain.com/sites/default/files/google_tag/google_tagmanager/google_tag.script.jsIf that doesn't work, try http:// instead of https://.Smartlook uses inline css, so you'll have to use hook_page_alter() to exclude that script, and then a javascript function to load the script on the jQuery event eu_cookie_compliance.changeStatus. If you have issues setting that up, the company I work for offers paid support for handling that scenario. Shouldn't take too many hours.
Comment #9
johnzzonYeah, I can confirm that it did work. I didn't notice any cookies from Google Analytics, but I think that was due to being on a different domain than the GTM was configured for. I can see the script being loaded properly when clicking accept on a category.