Cloudflare Analytics Beacon in AMP

Does anyone know if Cloudflare’s new analytics beacon js is allowed on AMP pages? I was going to give it a try but wanted to know if anyone else had any experience and hopefully success in implementing it.

1 Like

+1 Was hoping to move over from google analytics but don’t want to miss out on AMP pages.

We reached out to Cloudflare support and they didn’t seem to have the implementation planned at all. Asked for me to provide feedback on how it went for me. There are plenty of other systems that work in with amp analytics so it can be done.

For what its worth, reached out as well since I assume the more reach out the more likely this would end up on the roadmap. Their response is below and but I think they are confusing the dashboard analytics with the new analytics product. Will try turning on the AMP real url feature to see if that works.

From what I have gather from the team, as long as the analytics are embedded in the webpage itself, then customer can continue using analytics and they will see traffic with AMP Real URL turned on.

Wonder you have a specific use case when you are observing otherwise so I can share more details with our product team.

Their reply sounds like it’s for the new product. They give you code to embed into the page, and that triggers the analytics. If that embed stays in the AMP version of the page, then it should work. But AMP is not really under Cloudflare’s control. It’s served by Google, as I recall. If Google strips out the embed, you’d be out of luck.


You can try the following code. This may work.

<!-- Cloudflare AMP Web Analytics -->
<amp-script defer src="" data-cf-beacon='{"token": "YOUR-TOKEN-HERE"}'></amp-script>
<!-- End Cloudflare AMP Web Analytics -->

Not yet, but they plan to support AMP soon - from Cloudflare-Analytics FAQ