• Resolved k.borisov

    (@kborisov)


    Hi,

    I’m trying to run some A/B tests with Optimize on my AMP (WordPress) Website.
    I’m adding my analytics setup through the amp_analytics_entries filter provided by the plugin. I will show you the final HTML output in the source page.

    What I’ve done so far:

    1. I’ve made sure that both amp-experiment and amp-analytics scripts are included in my page(the WordPress plugin includes all the required scripts automatically.)
    2. Setup an experiment named testExperiment. Its ID is 51vXPC_HQcCA-kjuWP5XFQ.
    3. Potential problem: Optimize diagnostics shows the following errors:
      Analytics tracking code not found
      Optimize plugin not found
      Analytics is 100% integrated, as it shows live views on my website. I suppose that the diagnostics are not working correctly due to the specific AMP integration process.
    4. I’ve created a variant, created targeting rule, linked with analytics, set up an objective.
    5. I’ve added the following amp-experiment code in my page.?
      <amp-experiment>
      <script type="application/json">
      {
          "testExperiment": {
              "sticky": false,
              "variants": {
                  "0": 50,
                  "1": 50
              }
           }
      }
      </script>
      </amp-experiment>

      ?My analytics script looks like this:

      <script type="application/json">
              {
                  "vars": {
                      "account": "UA-54160702-17"
                  },
                  "requests": {
                      "experiment": "${pageview}&xid=${xid}&xvar=${xvar}"
                  },
                  "triggers": {
                      "trackPageview": {
                          "on": "visible",
                          "request": "pageview",
                          "extraUrlParams": []
                      },
                      "pageview": {
                          "on": "visible",
                          "request": "experiment",
                          "vars": {
                              "xid": "51vXPC_HQcCA-kjuWP5XFQ",
                              "xvar": "VARIANT(testExperiment)"
                          }
                      }
                  },
                  "transport": {
                      "beacon": "true",
                      "xhrpost": "true",
                      "image": "false"
                  }
              }
          </script>
    6. ?

    7. I’ve added the following CSS to my page:
      body[amp-x-testExperiment="0"] .clr-expr {
          background-color: #00cebe
      }
      body[amp-x-testExperiment="1"] .clr-expr {
          background-color: #353c8c
      }

    The experiment attribute is not added to the body of the page and I’m seeing the following errors in the console:
    [amp-experiment] Experiment amp-experiment-1.0 is not enabled.
    “Experiment amp-experiment-1.0 is not enabled.” <amp-experiment class=?”i-amphtml-element i-amphtml-notbuilt amp-notbuilt i-amphtml-layout-container i-amphtml-error” i-amphtml-layout=?”container”>?…?</amp-experiment>?
    failed to build: amp-experiment#1 Experiment amp-experiment-1.0 is not enabled.
    Uncaught (in promise) Experiment amp-experiment-1.0 is not enabled.

    The page I’m trying to test on is: https://dev.somnishop.com/was-tun-gegen-schnarchen-frauen/

    Any suggestions will be appreciated.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Can you include the amp-analytics wrapper element for the JSON script?

    Plugin Author Weston Ruter

    (@westonruter)

    Actually, I see the problem. The issue is that version 1.0 of amp-experiment is itself still experimental. The current stable version is 0.1. This issue came up before for amp-carousel, when 0.2 was made available but was still experimental: when upgrading the spec we had to force amp-carousel to be pinned at 0.1. See https://github.com/ampproject/amp-wp/pull/3084. At a later point we then rolled-back that pinning to 0.1 so that 0.2 could be used: https://github.com/ampproject/amp-wp/issues/3700

    I’ve created a workaround plugin which you can use to roll back the amp-experiment component script from 1.0 to 0.1 until 1.0 is stable: https://gist.github.com/westonruter/092828765f25c312e380c567f48f56e7

    We may put this fix into the AMP plugin as well. I missed this amp-experiment version update when updating the spec so I’ll make a note of looking out for this in the future.

    Plugin Author Weston Ruter

    (@westonruter)

    I opened an issue to track this: https://github.com/ampproject/amp-wp/issues/4628

    I think I’m running into a similar problem. I’m using the AMP plugin (obviously) and MonsterInsights Pro with the Google Analytics and AMP Addons enabled. I’ve set up Google Analytics (tracking fine in both Google Analytics itself and in MonsterInsights), and Google Optimize – which is running fine as long as I deactivate AMP.

    I’ve also installed the “amp-experiments script version rollback” plugin. The ‘add_action’ hook seems to be working – php exits if I put in an exit() statement in the anonymous function inside the add_action call in the php script.

    The problem is that I can’t get Google Optimize to work with AMP enabled. The live debugger for the page where I’m running the experiment (https://www.onlinecoursewizards.com/page-a/) says:

    “The Google Optimize snippet for the container with ID GTM-KD4XQRK is not correctly installed on this page. To preview experiences or debug the container, make sure the Google Optimize snippet is installed on any pages you want to test.”

    If I try to add a tag (in my template’s header.php file) to make sure the Optimize plugin is included:
    <script async custom-element=”amp-experiment”
    src=”https://cdn.ampproject.org/v0/amp-experiment-0.1.js”></script&gt;
    – then the tag is removed from the source code upon rendering the page.

    I was wondering if you’d have any tips to get Google Optimize to play nicely with AMP enabled?

    Plugin Author Alberto Medina

    (@albertomedina)

    @onnosolin Please open a separate issue to track it properly.

    In the meantime, have you checked this Optimize documentation? https://developers.google.com/optimize/devguides/amp-experiments

    @albertomedina Thanks for the tip. Yes, I had checked the Optimize documentation. Can’t get past the first step… (Code from first step is removed upon rendering the page in the browser.)

    I’ve opened a separated issue here, thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Google optimize integration’ is closed to new replies.