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.

Comments

KarenS created an issue. See original summary.

karens’s picture

Status: Active » Needs review
StatusFileSize
new589 bytes

Here is something that works for me:

rainbowarray’s picture

Assigned: Unassigned » rainbowarray
karens’s picture

StatusFileSize
new624 bytes

This is still an issue in latest code, but there was an error in the patch file, updating it:

rainbowarray’s picture

Status: Needs review » Needs work

Pretty sure this would remove the AMP metadata json, so this needs to be more finegrained.

rainbowarray’s picture

Status: Needs work » Reviewed & tested by the community

Turns out the AMP metadata JSON still shows up in head just fine. I think by the time preprocess_html fires, the metadata JSON attachment has already been bundled into the html head placeholder? That makes me wonder if it's possible for something else to sneak in through that route. I guess if we find something, we can track it down at that time. It seems like something with attachment bubbling is difficult to work with from the theme layer, but I'm not sure what the fix is.

  • mdrummond committed 13ab3d9 on 8.x-1.x authored by KarenS
    Issue #2716943 by KarenS: Google analytics script not removed
    
rainbowarray’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

berdir’s picture

Not sure what's different for amp.module, but my own application/ld+json element is being removed here. See #2770393: amptheme_preprocess_html() removes all script tags, even ld+json

playful’s picture

This is still an issue on 8.3. Does anyone have a solution that will work with this version?

cuman’s picture

+1

playful’s picture

Adding related issue.