• Closed by: Anonymous Submitter
  • Closed on:
  • Reason: Not a bug

Ticket #20784 - AMP Google Analytics

I entered GA ID in AMP configuration but I can’t get the analytics data in GA property and I see that this sniped

<amp-analytics type=”googleanalytics”>

<script type="application/json">
  {
    "vars": {
      "account": "G-39LBDFWSS4"
    },
    "triggers": {
      "trackPageview": {
        "on": "visible",
        "request": "pageview"
      }
    }
  }
</script>

</amp-analytics>

is loaden in <body> instead of <head>.

Could it be the problem?

As opposite, in website the tag is loaded in <head> and I get analytics without problems

<script type=”text/javascript”>

(window.gaDevIds=window.gaDevIds||[]).push('d6YPbH');
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
          ga('create', 'UA-46920287-2', 'auto');
              ga('set', 'userId', '1189');
                  ga('send', 'pageview');
  
  ga('require', 'ec');

</script>

Comments

Fred 16 Feb 2021, 14:31

you don’t have to add anything into the code, we already added all codes there
You just need to configure your google analytics for AMP, see the tutorial link in the AMP module settings