• Resolved Spacena

    (@spacena)


    This is really weird. This plugin removes the Google Analytics code. I have added GA code in header.php and I was able to read my users in GA console but once I installed this plugin, I found that the code is there in header.php but GA consoles shows now user realtime even when I visit it from desktop, mobile and Incognito at the same time.

    This plugin puts so much of code in the header when seen the source code but the GA code is missing. What is going on?

    My website is https://kunalparihar.in

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi!

    Why you don’t use “Analytics” section in AMP plugin settings to add your Google Analytics?
    Also you could try to add it correct via php code:
    https://amp.dev/documentation/components/amp-analytics/
    https://amp-wp.org/documentation/getting-started/analytics/

    Don’t use dirty solutions.
    I hope it helps.

    Thanks for opening a support topic. With custom JavaScript having some restrictions in the AMP framework the plugin removes custom JavaScript by default in order to maintain AMP validity. If you’ve placed the Google analytics snippet manually it’s normal the plugin will remove this from AMP URLs.

    As @nikitasp mentioned you can use the Analytics feature of the plugin or use Site Kit to place your snippet on your AMP URLs. From inspecting your site now I can see valid Analytics snippet on your AMP URLS so it looks like you’ve since managed to configure it correctly.

    This plugin puts so much of code in the header when seen the source code but the GA code is missing. What is going on?

    To improve performance and keep in line with AMP principles the plugin inlines all CSS after performing CSS treeshaking, which is why you may notice this addition code. If this wasn’t performed there would be more network requests for each stylesheet.

    We have some FAQs on the plugins website if you’d like to know more about how the plugin works.

    Let me know if you have any other queries in relation to the above and we’d be happy to help.

    Thread Starter Spacena

    (@spacena)

    Thanks for the reply. I did use site kit plugin and it fixed the problem. I was putting the GA code directly into the header.php earlier. Anyways, thanks guys ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘It removes GA code’ is closed to new replies.