---
title: "Ahrefs Web Analytics"
description: "Use Ahrefs Web Analytics in your Nuxt app to track page views and custom events with a privacy-first, cookie-less analytics script."
canonical_url: "https://scripts.nuxt.com/scripts/ahrefs-analytics"
last_updated: "2026-07-07T14:42:57.694Z"
---

[Ahrefs Web Analytics](https://ahrefs.com/web-analytics) is a privacy-first, cookie-less web analytics service from [Ahrefs](https://ahrefs.com) that tracks page views and custom events without sharing visitor data with third parties.

<script-stats>



</script-stats>

<script-docs>



</script-docs>

The composable comes with the following defaults:

- **Trigger: Client** Script will load when Nuxt is hydrating.

You can access the `AhrefsAnalytics` object as a proxy directly or await the `$script` promise to access the object. It's recommended to use the proxy for any void functions.

<code-group>

```ts [Proxy]
const { proxy } = useScriptAhrefsAnalytics({
  key: 'your-project-key',
})
function trackSignup() {
  proxy.AhrefsAnalytics.sendEvent('signup', {
    props: { plan: 'pro' },
  })
}
```

```ts [onLoaded]
const { onLoaded } = useScriptAhrefsAnalytics({
  key: 'your-project-key',
})
onLoaded(({ AhrefsAnalytics }) => {
  AhrefsAnalytics.sendEvent('signup', {
    props: { plan: 'pro' },
  })
})
```

</code-group>

## SPA navigation

Ahrefs Analytics tracks single-page-app navigations natively: the loaded `analytics.js` patches `history.pushState` and listens for `popstate`, firing a fresh page-view whenever the URL changes. Nuxt route changes need no extra configuration.

<script-types>



</script-types>

## Example

Loading Ahrefs Web Analytics through `app.vue` when Nuxt is ready.

```vue [app.vue]
<script setup lang="ts">
useScriptAhrefsAnalytics({
  key: 'your-project-key',
  scriptOptions: {
    trigger: 'onNuxtReady'
  }
})
</script>
```
