I am using the Google Analytics module. The normal Google Analytics script is appearing on AMP pages. This is independent of the AMP version of Google Analytics, which only appears when it's supposed to.

The Google Analytics module provides a way to exclude some paths for its script, but there is no way to exclude a path by a query string, only by normal paths, so there doesn't seem to be any way to use that to keep the non-AMP analytics off the page.

More details of the two techniques can be found at #2731279: Add google_analytics hook to skip default GA integration for AMP pages

Comments

playful created an issue. See original summary.

playful’s picture

I was able to resolve the second error by replacing 'responsive' with layout="responsive" in block--amp-system-branding-block.html.twig.

paultgreen’s picture

I'm also experiencing the issue with the Google Analytics module. When I disable the analytics module, my site returns as valid AMP on the Google validator, but when I re-enable it I get the error about custom scripts not being allowed.

Did you find a solution in the end?

playful’s picture

I was only able to get it to work with Google Analytics by using the AMP 8.2 version. Please update here if the 8.3 version becomes compatible with Google Analytics. Thanks!

nravens’s picture

I have Drupal 9.1.2 with AMP module Version: 8.x-3.5 and Google Analytics module 8.x-3.1 and also getting the Google Analytics validation error on my AMP pages.

How can we resolve this issue?

playful’s picture

Priority: Normal » Major
playful’s picture

Version: 8.x-3.0-alpha1 » 8.x-3.5
Status: Active » Closed (duplicate)
Related issues: +#2716943: Google analytics script not removed
playful’s picture

Issue summary: View changes
Status: Closed (duplicate) » Active
playful’s picture

Title: Google Analytics and responsive image errors » Google analytics script not removed

Updated title and added related issue. The approach mentioned in that issue is not working with AMP 8.x-3.5.

Does anyone have any other suggestions for how this could be addressed?

jedihe’s picture

To remove scripts added as html_head attachments, check this docs page.

For cases like mailchimp, check this method.

For more details about the two techniques, check #2731279: Add google_analytics hook to skip default GA integration for AMP pages