I’m trying to add Ahrefs Analytics service to some of my websites hosted on Netlify and built with Nuxt.
Specifically, we can take https://links.stefanobartoletti.it/ as an example.
I’ve correctly added the script to my website head
, like this
<script src="https://analytics.ahrefs.com/analytics.js" data-key="xxxxxxxxxxxxxxxxxxxxx" async></script>
But it is not detected, and after contacting Ahrefs support, they told me that their bot is receiving a different response and that it cannot see it:
Our team mentioned your webserver is answering something different to our bot:
To get verification working you should also have the <script … tag when responding to our bot.
Bot User-agent containing: 'AhrefsSiteAudit and +http://ahrefs.com/robot/site-audit
Basically - the webserver is answering different HTML for our bot (and likely other robots)
The discrimination is based on the User-agent header
How can I allow this specific bot to receive the correct data it needs (without allowing all other bots, of course)?