How to insert Analytics code into AMP without extra plugins?

The AMP has changed everything and put Google Analytics in AMP it is not as intuitive as it seems. Google’s trend towards Mobile-friendly has meant that thousands of people have improved our projects, adapted their themes to mobile phones and also encouraged us to put AMP on our websites. AMP is such a closed architecture that sometimes simple things are difficult to integrate. If you wonder how to integrate the Analytics code into the official AMP plugin, here we explain it step by step, so you have no doubts.

With this post you can put Analytics in AMP without resorting to add-ons and without having to put the code back into the plugin every time you update it to its latest version.

This is the method to put Analytics in AMP with the official plugin

The first thing you need is to have the tracking code, a numerical combination of type UA-XXXXX-Y. You can get this in the Analytics settings.

  • Go to Analytics.
  • Click on Manage
  • Select Tracking Information, then Tracking Code, and copy the code.

Analytics Code in AMP

Once you have it, now is the time to insert Analitycs into the official AMP plugin. You will see that there is an option enabled for it in the WordPress menu.

  • Look for AMP in the Admin sidebar and go to Analytics.

Put Analitycs in AMP

You may also be interested in:

Once here you have practically everything done, you only need to adjust the code that is officially integrated into the plugin and in this way you avoid having to change it every time you update AMP (in case you had inserted it in the plugin files).

  • In type write googleanalytics (and be careful to write it well or it will not work).
  • Then, copy the following code and where you put your number, use the tracking code that we have extracted from Analytics.
  • Finally save the changes (the image may vary depending on the version of AMP but the process is exactly the same).
	"vars": {
		"account": "UA-XXXXX-Y"
	"triggers": {
		"trackPageview": {
			"on": "visible",
			"request": "pageview"

Put Analytics in JSON

It’s that simple, with these steps you will have Analytics working. If you have recently changed and you think you have lost traffic, you may find in these visits everything that you are missing or you may even realize that it has improved a lot since you have made the change to AMP. If you would like to see more tutorials of these on the web, leave us a comment. And if you have doubts, too. We hope we have helped you with something so simple that we did not find any good tutorial In Internet.

There are other easier ways to do it like using the classic Yoast and AMP SEO plugin but it is not necessary to use it. You see that it is not difficult, the only thing is that there is no good information about it.

You may also be interested in:


How useful did you find this content?

Click on a star to rate!

Average score 0 / 5. Counting of votes: 0

So far, no votes. Be the first to rate this content.

I'm sorry this content was not useful for you!

Let me improve this content!

Tell me, how can I improve this content?

Deja un comentario