Issues implementing amp-consent

730 Views Asked by At

I've implemented the example for a basic consent flow. However, users still get tracked and ads are still showing even if they opt-out.

I had a working cookie notice with <amp-notification>, but now that I like to place ads I need a consent mechanism. The opt-out has no effect. Ads still shown and visitors still tracked.

This is the part from the <body>. I dont think that I have any issues in the <head> section:

<amp-consent id="myUserConsent" layout="nodisplay">
    <script type="application/json">{
      "consents": {
            "consent1": {
              "checkConsentHref": "https://preview.amp.dev/documentation/examples/api/get-consent",
              "promptUI": "consentDialog"
            }
          },
          "postPromptUI": "post-consent-ui"
        }</script>
    <div class="popupOverlay" id="consentDialog">
      <div class="consentPopup">
        <div class="dismiss-button" role="button" tabindex="0" on="tap:myUserConsent.dismiss">X</div>
        <h2>Cookie Notice</h2>
        <p> Wir nutzen auf unserer Website Cookies und andere Technologien, um zu analysieren wie Sie unsere Webseite nutzen, Inhalte zu personalisieren und Werbung zu schalten. Durch die weitere Nutzung erklären Sie, dass Sie mit der Nutzung von Cookies einverstanden sind. Beachten Sie bitte, dass dieser Hinweis und die Einstellungen nur für die AMP Version unserer Seite gelten. Auf der regulären Website treffen Sie die Auswahl über den Cookiebot. Weitere Informationen erhalten Sie in unserer <a href=https://www.xxxx.de/datenschutzerklaerung>Datenschutzerkärung</a> und im <a href=https://www.xxxx.de/impressum/amp>Impressum.</a></p>
        <button on="tap:myUserConsent.accept">OK</button>
        <button on="tap:myUserConsent.reject">Ablehnen</button>
      </div>
    </div>
    <div id="post-consent-ui">
      <button on="tap:myUserConsent.prompt()">Zustimmung zu Cookies überarbeiten</button>
    </div>
  </amp-consent>

This is the part for analytics:

<amp-analytics data-block-on-consent type="googleanalytics">
        <script type="application/json">
            {
                "vars": {
                    "account": "UA-xxxxxxxx-x"
                },
                "triggers": {
                    "trackPageview": {
                        "on": "visible",
                        "request": "pageview"
                    }
                }
            }
        </script>
    </amp-analytics>

And this for adsense:

<amp-ad data-block-on-consent width="100vw" height=320
     type="adsense"
     data-ad-client="ca-pub-xxxxxx"
     data-ad-slot="1046841879"
     data-auto-format="rspv"
     data-full-width>
  <div overflow></div>
</amp-ad>

I have no errors so far. I checked the website with validator.ampproject.org.

0

There are 0 best solutions below