In this article, I will show you how to add Clicky analytics to your AMP site.
If you are reading further, I assume that you have some basic knowledge about WordPress functions, hooks and how they work, but I’ll explain to you which code does what.
As we have analytics code already in our AMP plugin, so now let’s remove existing code, before adding our own, as we don’t want two analytics code.
Paste this code at the end of your theme’s functions.php or create a new plugin to create a plugin read this detailed article on how we can create a plugin on top of AMP.
Remove existing AMP analytics
Below code will remove all the existing amp-analytics code.
Add Clicky analytics code
Please make sure you add your Clicky site id in “site_id”: “YOUR_SITE_ID_HERE” , you can find site id of your clicky account from here
Hook Clicky analytics into AMP
This code will hook clicky analytics code into the AMP pages.
This is the final code.
I hope this article will help you understand how we can modify the output and also with this tutorial you can not only add Clicky but all the amp supported analytics, here is the list of all the supported AMP Analytics Vendors
Do let me know your feedback and your suggestion on how we can improve our plugin.