Closed (fixed)
Project:
EU Cookie Compliance (GDPR Compliance)
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Jul 2018 at 16:02 UTC
Updated:
18 Sep 2021 at 10:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
frank pfabigancommenting-out line 311 - 320 of file eu_cookie_compliance.module fixes the problem, but there must be a better way :-)
Comment #3
svenryen commentedI'll see if we can make the module work better with AMP. Thanks for the report!
Comment #4
tarasichAt the moment the only way to make EU Cookie Compliance module work with AMP is disable it and use what AMP specification says to use ))
Its forbidden to use third party JS on AMP pages, which makes it impossible to use something except what AMP have in it.
See documentation about amp-user-notification element and try to make it work.
I used something like this:
Where 'data_show_if_href' and 'data_dismiss_href' are two API endpoints which GETs and POSTs cookies which are used on main non-AMP pages by EUCC module. So if user accepted cookies on main site, he will not see the popup on AMP pages.
Comment #5
igonzalez commentedGood morning,
Has anyone found a solution to this problem?
Greetings and thanks
Comment #6
marcosdr commentedHi,
As a solution for now, you can conditionally remove the unwanted style asset provided by the eu cookie compliance via hook_page_attachments_alter()
Add the following to your .theme file inside your amp theme folder.
Comment #7
svenryen commentedSo what we'll have to do is check if the page is being viewed as AMP, and then remove the inline css?
Comment #8
marcosdr commentedor you could wrap the attachment within some logic that checks if the current theme is based on an AMP theme. Something like
Comment #9
svenryen commentedif ($theme->getName() == 'amptheme') {This seems to only work with https://www.drupal.org/project/amptheme
What about custom AMP implementations?
Comment #10
marcosdr commentedTrue, you could check if the module exists and is enabled first.
Comment #11
EurekaWeb commentedIs there any patch or other solutions for this?
Our site's AMP pages were all affected and finally tracked to this module as the cause.
We have disable the module for now while allowing the errors to clear in Google Console to restore our impression stats.
There is an option to exclude path in the advanced settings tab but inserting */?amp* doesn't seem to have any effects.
Comment #12
svenryen commented@Eurekaweb: What does the amp paths look like? Do you have an example?
Comment #13
EurekaWeb commentedWhen AMP pages are available the typical path would be the url?amp
Comment #14
svenryen commentedIn that case, can you use XDebug to check that your path is actually being excluded.
If you entered literally "*/?amp*" as an option to exclude, I don't think it would match a URL being http(s)://domain.com/page?amp
It would however match "http(s)://domain.com/page/?amp"
(notice the trailing slash to make your pattern match.)
Comment #15
EurekaWeb commentedSorry for the late response. Missed your reply.
The amp url typically results in this format:
http(s)://domain.com/page?amp
So the when "*/?amp*" is setup to exclude resulting "http(s)://domain.com/page/?amp" would not work to exclude.
Any suggestions on how to accomplish the exclusion or any other work arounds?
Thanks
Comment #16
svenryen commentedI hear you, but I haven't had time to look into the issue.
Meanwhile, can you change your pattern into *?amp and see how that works?
Even if it did work, your pattern "*/?amp*" doesn't match "http(s)://domain.com/page?amp", though it seems to match "http(s)://domain.com/page/?amp"
(Notice, again, the slash in your pattern)
Comment #17
DocRPP commentedI can confirm that adding '*?amp' as the option to exclude didn't work. I am after this feature as well, so request if anyone can take this up.
Comment #18
pick_d commentedFor me even uninstalling the module (using admin interface, and even purging configs with easy_install and even after deleting the module folder) doesn't help at all.
Somehow there's more than 100 entries containing "eu_cookie_compliance" in database. Not sure if it's designed to be like this or I did something wrong.
Any help to safely purge database from those entries?
(Blunt force like simply manually removing all them doesn't work as intended, tried already. Good that I make backups all the time)
Comment #19
svenryen commentedpick_d, are you using D7 or D8?
And can you let me know how your report is related to problems verifying the site under AMP?
Comment #20
mikechr commentedUpgrading this to major, because each update of the module breaks amp pages for all my sites.
Do we have a roadmap for this?
Comment #21
svenryen commentedI hear you. If all goes according to plan, all bug reports will be cleared within a month. That's assuming no single issue requires several days to resolve.
Patches are always welcome.
Comment #22
svenryen commentedIf somebody could help summarize a list of all changes that needs be done in order for the module to support AMP, that could really help.
Do I understand it correctly, that if AMP is detected, we want to just skip adding any js or css to the page?
Is there anything we could do to replace functionality under AMP?
From what I understand, we can leverage
amp-user-notification.I have to admit I haven't worked with AMP implementations, so I'd have to read up a bit.
Comment #23
mikechr commented@scenryen
Currently just skipping the style tags in the html fixes the problem. Specifically
415:421 in eu_cookie_compliance.module
Comment #24
svenryen commentedSo then the additional requirement from #4 is wrong.
I would assume this means we should also omit JS, but that's maybe handled by an amp-module?
Comment #25
mikechr commentedyes it is most likely that the js is picked up by the AMP library
Comment #26
FirstSanny commentedWhat is the current state on this topic?
For the list of all changes i think we need:
- A proper documentation of how to do things:
+ Disable JS and CSS.
We are using #6 and added
eu_cookie_compliance/eu_cookie_compliance: falseto themy_theme.info.yml+ Explaining which additional libraries should be included. amp-user-notification and amp-analytics
+ Explain how to create the right notification html and where to place it.
- Create a api to see if there was givven a consent (GET) and to publish a consent (POST)
I think the way @tarasich in comment #4 tried to do it is the best. Because if you would leave out the api part, then the user would have to accept again, when you leave the amp site and go to your main, which isn't probably in amp.
Comment #27
svenryen commentedSo the issue is that we sometimes handle user data under AMP even though no js files are loaded? We're displaying the banner using js, so based on this issue I'm not really sure how we can do that on AMP, let alone set cookies to indicate the user wants to be tracked.
Is an acceptable solution to simply "disable" the module output when AMP is being used?
Comment #28
FanisTsiros commentedHello
Please let me clarify something important. AMP pages are served from Google.
AMP pages accessibility by our site users with /?amp urls IS possible but this is NOT the purpose of AMP pages.
Yes, google reads a non AMP page, then, this page informs Google bot that there is an AMP alternate page and then Google makes the AMP page available through a URL like:
https://news.google.com/articles/CBMidWh0dHA6Ly9hbmFnbm9zdGlzLm9yxxxxxxxxxxxxxxxxxxxxxxxxThe important here is that we DO NOT need cookies conset from our users because when they are in our AMP page, actually they are inside Google's domain.
In my opinion, this means that EU Cookie Compliance module should not load at all in AMP pages.
Comment #29
mugensama commentedHello,
I had the exact same problem today with amp and a website with eu cookie.
I made a patch to remove all code from eu_cookie_compliance_preprocess_page() in the .module file when the current theme in amptheme or a theme based on amptheme.
It's perhaps not the greatest patch but I don't need eu_cookie on the amp theme, I'll add the amp code for this.
And the error was a major issue with my website at the moment.
Hope it can helps if someone has the same issue.
Comment #30
svenryen commentedThanks for your patch @mugensama.
Do you know if most sites use this theme for their amp purpose?
Can you please tidy up your patch as per Drupal coding standards? The opening curly bracket should be on the same line as the function name. https://www.drupal.org/docs/develop/standards is a helpful guide, so is running CodeSniffer.
Also, we don't need the rather long else branch, since if the 'if' condition is hit, the function will return.
Comment #31
mugensama commentedThanks @svenryen, i'll try update the patch asap
I think the amptheme should be the default theme for amp purpose (because of all the changes already done to templates), and creating a child theme base on this feels like it's the best practice for custom amp pages.
Comment #32
mohammad-fayoumiThanks for your patch @mugensama.
I just faced the same issue while I'm validating my AMP pages.
Just I have refactored the patch as per Drupal coding standards.
Comment #33
mohammad-fayoumiComment #34
mohammad-fayoumiThe patch on #32 for version 8.x-1.x-dev
This patch is only for version: '8.x-1.14' until the patch #32 patch committed in the next release.
Comment #35
svenryen commentedComment #36
svenryen commentedPatch looks good. I tested the generated code using Bartik AMP against the validator at https://search.google.com/test/amp and although I got a number of unrelated errors, I didn't get any error on inline css.
For clarity, I updated the patch with an additional () around the if statement, since my IDE complained it was ambiguous.
if ((!empty($parents_theme) && array_key_exists('amptheme', $parents_theme)) || $themeName === "amptheme") {Comment #38
svenryen commentedComment #39
rar9 commentedI try this new patch #36 to what I had before as a manual patch but both can't be applied. anymore :-(
I have $themeName === "bartik_amp"
Comment #40
svenryen commented@Rar9 are you applying the patch to the latest dev-version from git?
Is bartik_amp not a sub-theme of "amptheme"?
Comment #41
rar9 commented@svenryan Yes, I used the bartic_amp amp subtheme for my amp pages in conjuction with
drupal/amp 3.5.0 Google AMP integration
drupal/amptheme dev-3.x 7d65ca8 The AMP Base theme converts core templates to use AMP HTML.
Both patches current the wont apply :-(
Comment #43
svenryen commented@Rar9. We're working on getting a new version out. Until then feel free to run the -dev version.