Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FIRST_PARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Four presets in `proxy-configs.ts` cover all proxy-enabled scripts:
| `PRIVACY_HEATMAP` | ip, language, hardware | GA, Clarity, Hotjar |
| `PRIVACY_IP_ONLY` | ip only | PostHog, Plausible, Umami, Rybbit, Databuddy, Ahrefs, Fathom, Vercel, Matomo, Carbon Ads, Lemon Squeezy, Intercom, Gravatar, YouTube, Vimeo, Calendly |

Note: Cloudflare Web Analytics, TikTok, GTM, Segment, Crisp, Mixpanel, Bing UET, SpeedCurve, Pulse, and Statable have no proxy capability, so no privacy transforms are applied.
Note: Cloudflare Web Analytics, TikTok, GTM, Segment, Crisp, Mixpanel, Bing UET, SpeedCurve, Pulse, Statable, and MetricRaven have no proxy capability, so no privacy transforms are applied.

## Script Support

Expand Down
1 change: 1 addition & 0 deletions docs/content/docs/1.guides/2.first-party.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ These integrations serve their main loader from your domain, but some runtime re
| [Fathom](/scripts/fathom-analytics) | Fathom's bot detection rejects beacons from the server's IP, so Nuxt Scripts bundles the SDK but leaves beacons direct. |
| [Pulse](/scripts/pulse-analytics) | Pulse identifies visitors from the connecting IP, so proxied beacons would merge everyone into one visitor. Nuxt Scripts bundles the tracker but leaves beacons direct. |
| [Statable](/scripts/statable-analytics) | Statable identifies visitors from the connecting IP and user agent, so proxied beacons would merge everyone into one visitor. Nuxt Scripts bundles the tracker but leaves beacons direct. |
| [MetricRaven](/scripts/metricraven-analytics) | Without storage consent, MetricRaven derives a daily visitor ID from the client IP, which a proxy has to forward in an `x-visitor-ip` header. Nuxt Scripts bundles the tracker but leaves beacons direct. |
| [Segment](/scripts/segment) | SDK constructs API URLs dynamically, bypassing request interception. |
| [Crisp](/scripts/crisp) | SDK loads secondary scripts and CSS at runtime from `client.crisp.chat`. |
| [Mixpanel](/scripts/mixpanel-analytics) | No proxy integration yet. |
Expand Down
113 changes: 113 additions & 0 deletions docs/content/scripts/metricraven-analytics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: MetricRaven
description: Load the MetricRaven tracker, record goals and identify users.
seoTitle: MetricRaven Setup for Nuxt
seoDescription: Add the MetricRaven tracking script to a Nuxt app, record goals, identify users and pass the visitor ID to your checkout from a typed composable.
links:
- label: Source
icon: i-simple-icons-github
to: https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/registry/metricraven-analytics.ts
size: xs
---

[MetricRaven](https://metricraven.com/) is web analytics that attributes revenue from your payment provider to the visit that brought each customer. It sets no cookies until you grant storage consent. The [install guide](https://metricraven.com/docs/install) lists the tracker's options.

::script-stats
::

::script-docs
::

## Proxying is not supported

Without storage consent, MetricRaven derives a daily visitor ID from the client IP. A proxy has to forward that IP in an `x-visitor-ip` header, which the Nuxt Scripts proxy does not do, so beacons sent through it would merge every visitor into one.

You can bundle the tracker on your Nuxt origin. Events still go to MetricRaven. The composable sets `data-api` and `data-addons` on the script tag, so the bundled copy keeps sending to the tracker's origin.

To serve everything from your own domain, use MetricRaven's [managed proxy](https://metricraven.com/docs/managed-proxy) and set `apiHost`, or a [server route](https://metricraven.com/docs/proxy-vue-nuxt) of your own and set `scriptUrl` and `endpoint`:

::code-group

```ts [Managed proxy]
useScriptMetricRavenAnalytics({
siteId: 'ana_pub_…',
apiHost: 'https://a.example.com',
})
```

```ts [Server route]
useScriptMetricRavenAnalytics({
siteId: 'ana_pub_…',
scriptUrl: '/a/script',
endpoint: '/a/event',
})
```

::

## Goals

Use `proxy.track(name, props)`{lang="ts"} to record a goal. Calls made before the tracker loads run once it is ready. Properties can be strings, numbers or booleans.

::code-group

```ts [Proxy]
const { proxy } = useScriptMetricRavenAnalytics()
function trackSignup() {
proxy.track('signup', { plan: 'pro' })
}
```

```ts [onLoaded]
const { onLoaded } = useScriptMetricRavenAnalytics()
onLoaded(({ track }) => {
track('newsletter_signup')
})
```

::

Elements with a `data-goal="name"` attribute are tracked on click without code. See [Goals & funnels](https://metricraven.com/docs/goals-funnels).

Check warning on line 70 in docs/content/scripts/metricraven-analytics.md

View workflow job for this annotation

GitHub Actions / lint

Passive voice: "are tracked". Consider rewriting in active voice

## Identify users

`identify` labels the current visitor with your user ID and traits. For a verified identity, pass a token your server signed, either with `identify({ token })`{lang="ts"} or the `identityToken` option. See [Identify users](https://metricraven.com/docs/identify-users).

```ts
const { proxy } = useScriptMetricRavenAnalytics()
proxy.identify(user.id, { name: user.name, email: user.email })
```

## Revenue attribution

To credit a payment to the visit, send the visitor ID to your checkout and on to your payment provider's metadata. See [Connect a payment provider](https://metricraven.com/docs/connect-payment-provider).

```ts
const { onLoaded } = useScriptMetricRavenAnalytics()
onLoaded(({ getVisitorId }) => {
checkoutMetadata.metricraven_visitor_id = getVisitorId()
})
```

## Consent

Until storage consent is granted, the tracker stores nothing in the browser. Set `consent: true` when your banner's saved choice already allows it, or call `proxy.setConsent(true)`{lang="ts"} when the visitor accepts. See [Consent](https://metricraven.com/docs/consent).

## Page views in Nuxt

The tracker records client-side navigation without extra setup. Set `autoPageviews: false` to call `proxy.pageview(path)`{lang="ts"} yourself, and `hashRouting: true` for hash-mode routers.

::script-types
::

## Example

The default trigger waits until Nuxt is ready:

```vue [app.vue]
<script setup lang="ts">
useScriptMetricRavenAnalytics({
siteId: 'ana_pub_…',
})
</script>
```
4 changes: 4 additions & 0 deletions packages/script/src/registry-logos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const LOGOS = {
light: `<svg width="32" height="32" viewBox="0 0 37 37" xmlns="http://www.w3.org/2000/svg"><path fill="#0061FE" d="M12.2927 25.5017C15.736 28.719 19.7446 31.3835 22.7253 31.9867C17.8945 35.1035 11.3676 34.7013 6.84512 30.8304L12.2927 25.5017Z"/><path fill="#0061FE" d="M18.8709 19.1172C24.1642 24.4962 25.963 29.2218 24.8837 30.3277C23.7531 31.3834 18.9222 29.6741 13.4233 24.4459L18.8709 19.1172Z"/><path fill="#0061FE" d="M25.3977 12.7328C29.3548 17.1064 29.766 23.4908 26.5797 28.2666C25.963 25.3508 23.2391 21.3794 19.9501 18.0615L25.3977 12.7328Z"/><path fill="#0061FE" d="M11.162 7.85642C11.7787 10.7722 14.5025 14.7436 17.7916 18.0615L12.344 23.3902C8.38689 19.0166 7.97571 12.6322 11.162 7.85642Z"/><path fill="#0061FE" d="M12.858 5.79526C13.9886 4.73957 18.8195 6.44878 24.3184 11.677L18.8709 17.0058C13.5262 11.6268 11.7787 6.90124 12.858 5.79526Z"/><path fill="#0061FE" d="M14.9651 4.13641C19.8473 1.0196 26.374 1.4217 30.8451 5.29255L25.3977 10.6213C21.9544 7.40399 17.9458 4.73967 14.9651 4.13641Z"/></svg>`,
dark: `<svg width="32" height="32" viewBox="0 0 37 37" xmlns="http://www.w3.org/2000/svg"><path fill="#fff" d="M12.2927 25.5017C15.736 28.719 19.7446 31.3835 22.7253 31.9867C17.8945 35.1035 11.3676 34.7013 6.84512 30.8304L12.2927 25.5017Z"/><path fill="#fff" d="M18.8709 19.1172C24.1642 24.4962 25.963 29.2218 24.8837 30.3277C23.7531 31.3834 18.9222 29.6741 13.4233 24.4459L18.8709 19.1172Z"/><path fill="#fff" d="M25.3977 12.7328C29.3548 17.1064 29.766 23.4908 26.5797 28.2666C25.963 25.3508 23.2391 21.3794 19.9501 18.0615L25.3977 12.7328Z"/><path fill="#fff" d="M11.162 7.85642C11.7787 10.7722 14.5025 14.7436 17.7916 18.0615L12.344 23.3902C8.38689 19.0166 7.97571 12.6322 11.162 7.85642Z"/><path fill="#fff" d="M12.858 5.79526C13.9886 4.73957 18.8195 6.44878 24.3184 11.677L18.8709 17.0058C13.5262 11.6268 11.7787 6.90124 12.858 5.79526Z"/><path fill="#fff" d="M14.9651 4.13641C19.8473 1.0196 26.374 1.4217 30.8451 5.29255L25.3977 10.6213C21.9544 7.40399 17.9458 4.73967 14.9651 4.13641Z"/></svg>`,
},
metricravenAnalytics: {
light: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="32" height="32"><path fill="#3A4253" fill-rule="evenodd" d="M3 6l30 0-8 11z"/><path fill="#171B24" fill-rule="evenodd" d="M33 6l10 7-3 5-15-1z m-4.5 10l7.5-4.5-1.5 6z"/><path fill="#2A3040" fill-rule="evenodd" d="M43 13l19 10-16-0.5-6-4.5z"/><path fill="#2A3040" fill-rule="evenodd" d="M14 11.5l11 5.5-5 15-16.5-7z"/><path fill="#3A4253" fill-rule="evenodd" d="M25 17l15 1 6 4.5-8 4.5-18 5z"/><path fill="#3A4253" fill-rule="evenodd" d="M3.5 25l16.5 7 2 28-19-25z"/><path fill="#171B24" fill-rule="evenodd" d="M20 32l18-5 3.5 10-19.5 23z"/><path fill="#38D9E6" fill-rule="evenodd" d="M28.5 16l7.5-4.5-1.5 6z"/></svg>`,
dark: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="32" height="32"><path fill="#A9B3C1" fill-rule="evenodd" d="M3 6l30 0-8 11z"/><path fill="#F8FAFC" fill-rule="evenodd" d="M33 6l10 7-3 5-15-1z m-4.5 10l7.5-4.5-1.5 6z"/><path fill="#D3D9E2" fill-rule="evenodd" d="M43 13l19 10-16-0.5-6-4.5z"/><path fill="#D3D9E2" fill-rule="evenodd" d="M14 11.5l11 5.5-5 15-16.5-7z"/><path fill="#A9B3C1" fill-rule="evenodd" d="M25 17l15 1 6 4.5-8 4.5-18 5z"/><path fill="#A9B3C1" fill-rule="evenodd" d="M3.5 25l16.5 7 2 28-19-25z"/><path fill="#F8FAFC" fill-rule="evenodd" d="M20 32l18-5 3.5 10-19.5 23z"/></svg>`,
},
matomoAnalytics: `<svg xmlns="http://www.w3.org/2000/svg" width="56.5" height="32" viewBox="0 0 256 145"><defs><path id="logosMatomoIcon0" d="m105.426 70.887l.035-.021l-.663-1.01c-.1-.153-.2-.313-.303-.46L58.935 0L0 43.91l43.078 66.305c.185.281.36.566.55.847l.229.35l.025-.016c6.676 9.471 17.678 15.673 30.144 15.673c20.373 0 36.889-16.513 36.889-36.89c0-7.083-2.029-13.675-5.489-19.292"/><path id="logosMatomoIcon1" fill="#000" d="M64.549 19.33c0-20.374-16.517-36.89-36.89-36.89S-9.23-1.044-9.23 19.33a36.686 36.686 0 0 0 6.08 20.263c-.003 0-.003 0-.003-.003l-.019.003L-31.179 0h-.04c-6.499-10.524-18.101-17.56-31.376-17.56c-13.275 0-24.877 7.036-31.376 17.56h-.037l-44.61 69.525c6.633-9.8 17.848-16.235 30.57-16.235c13.39 0 25.077 7.158 31.54 17.832h.047l29.15 40.921h.047c6.718 9.1 17.486 15.026 29.663 15.026c12.181 0 22.95-5.927 29.666-15.026h.05l.297-.46a36.949 36.949 0 0 0 2.116-3.312l43.675-68.256v.003A36.747 36.747 0 0 0 64.55 19.33M2.372 46.141c.213.204.435.397.654.594c-.22-.197-.438-.39-.654-.594m3.28 2.745c.243.181.48.369.728.544c-.247-.175-.485-.363-.729-.544m8.096 4.598c.306.128.628.228.94.347c-.312-.12-.634-.22-.94-.347m8.28 2.263c.428.065.853.143 1.287.197c-.434-.054-.856-.132-1.287-.197m9.93.203c.438-.05.869-.135 1.303-.197c-.434.062-.862.147-1.303.197m8.368-2.01c.393-.144.797-.275 1.184-.434c-.387.159-.788.29-1.185.434m8.368-4.326c.313-.216.61-.456.916-.684c-.307.228-.603.465-.916.684m6.258-5.526c.259-.285.528-.563.778-.857c-.25.294-.519.572-.778.857"/><path id="logosMatomoIcon2" fill="#95C748" d="m250.511 88.448l.035-.022l-.663-1.01c-.1-.153-.2-.312-.303-.46L204.02 17.56l-58.935 43.91l43.078 66.305c.185.281.36.566.55.847l.229.35l.025-.016c6.676 9.471 17.678 15.673 30.144 15.673c20.373 0 36.889-16.513 36.889-36.89c0-7.083-2.029-13.675-5.489-19.291"/><filter id="logosMatomoIcon3" width="106.9%" height="109.7%" x="-3.4%" y="-3.5%" filterUnits="objectBoundingBox"><feOffset dy="2" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="2"/><feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0"/></filter></defs><use href="#logosMatomoIcon2"/><path fill="#35BFC0" d="M73.779 107.74c0-20.374-16.516-36.89-36.89-36.89C16.516 70.85 0 87.366 0 107.74c0 20.376 16.516 36.892 36.89 36.892c20.373 0 36.889-16.52 36.889-36.893"/><path fill="#3253A0" d="M172.744 0c20.373 0 36.89 16.516 36.89 36.89a36.747 36.747 0 0 1-6.346 20.688v-.003l-43.675 68.256a36.949 36.949 0 0 1-2.116 3.313l-.297.46h-.05c-6.717 9.098-17.485 15.025-29.666 15.025c-12.177 0-22.945-5.927-29.663-15.026h-.046l-29.15-40.921h-.047C62.114 78.008 50.427 70.85 37.036 70.85c-12.721 0-23.936 6.436-30.569 16.235l44.61-69.525h.037C57.613 7.036 69.215 0 82.49 0c13.275 0 24.877 7.036 31.376 17.56h.04l28.006 39.593l.02-.003c0 .003 0 .003.002.003a36.684 36.684 0 0 1-6.08-20.264C135.855 16.516 152.372 0 172.745 0"/><use href="#logosMatomoIcon2"/><g transform="translate(145.085 17.56)"><mask id="logosMatomoIcon4" fill="#fff"><use href="#logosMatomoIcon0"/></mask><g mask="url(#logosMatomoIcon4)"><use filter="url(#logosMatomoIcon3)" href="#logosMatomoIcon1"/></g></g><path fill="#F38334" d="M209.487 36.89c0-20.374-16.516-36.89-36.89-36.89c-20.373 0-36.89 16.516-36.89 36.89c0 20.373 16.517 36.889 36.89 36.889c20.374 0 36.89-16.516 36.89-36.89"/><path fill="#3152A0" d="M172.597 73.782c-12.887 0-24.214-6.617-30.81-16.629h-.021L113.759 17.56h-.04C107.22 7.04 95.618.003 82.343.003C69.068.003 57.466 7.04 50.967 17.56h-.037L6.323 87.085c6.63-9.796 17.848-16.232 30.566-16.232c13.39 0 25.08 7.155 31.545 17.829h.047l29.15 40.921h.044c6.72 9.096 17.488 15.029 29.665 15.029c12.178 0 22.946-5.93 29.663-15.029h.05l.297-.462a37.588 37.588 0 0 0 2.12-3.307l43.672-68.256c-6.636 9.774-17.839 16.204-30.545 16.204"/></svg>`,
rybbitAnalytics: {
light: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 263.33 173.53" width="37.24" height="32"><g><polygon fill="#0a3a3a" points="181.28 171.2 227.21 123.96 261.15 171.2 181.28 171.2"/><path fill="#0a3a3a" d="M261.15,89.05L206.64,2.33l-33.22,17.75-34.61-7.4c2.88,5.56,4.56,12.11,4.56,19.15,0,20.03-13.46,36.26-30.06,36.26-13.66,0-25.17-11-28.83-26.06l-39.92,71.46L2.18,94.19l22.66,77.01h55.81l22.28-54.01v54.01h64.66l-49.95-82.15h143.51Z"/></g><ellipse fill="#0a3a3a" cx="105.94" cy="28.62" rx="12.9" ry="18.88"/></svg>`,
Expand Down
Loading
Loading