casey
casey

Reputation: 25

uBlock blocking amp-experiment

I am trying to implement an a/b test using amp-experiment.

.html file:

<amp-experiment>
  <script type="application/json">
      {
        "a-experiment": {
          "variants": {
            "control": 50,
            "1": 50
          }
        }
      }
    </script>
</amp-experiment>

<h3 class="a-experiment control">Sample control offer</h3>
<h3 class="a-experiment variant">Sample variant offer</h3>

.scss file:

body .control {
   display: block;
}

body {
   &[amp-x-a-experiment="control"] .variant {
      display: none;
   }
   &[amp-x-a-experiment="1"] .control {
     display: none;
   }
}

It works fine unless the user has uBlock Origin enabled. There are 2 problems here:

There are 2 error msgs:

If I remove the amp-experiment, there are no issues with uBlock.

Has anyone else encountered this issue? Is there a work around?

Upvotes: 2

Views: 994

Answers (1)

Sebastian Benz
Sebastian Benz

Reputation: 4288

uBlock (and potentially others) block requests to https://cdn.ampproject.org/v0/amp-analytics-0.1.js. This is most likely the result of the amp-analytics requests being part of the EasyList filters.

Blocking amp-analytics is the wrong choice as this request only downloads a webcomponent script which is required for AMP pages to work correctly. The request does not perform any actual tracking. Trackers make separate requests which should be covered by the existing filters.

I've asked the EasyList maintainers to remove amp-analytics from their list.

Update: they removed amp-analytics from EasyList.

Upvotes: 5

Related Questions