Enable privacy-friendly web analytics in your Vue.js 3.x application with our official plugin.
Wide Angle Analytics is powerful, strictly-GDPR compliant Google Analytics alternative.
You can enable Wide Angle Analytics in your Vue.js projects in just few steps. No complex configuration needed as our sane defaults give you reliable and privacy centric deployment out of the box.
- Go to Wide Angle website, create an account. You can create free 14-day trail. No Credit Card is required. Learn more.
- Create new Site and activate it.
- Install
wideangle-vuejs
plugin in your Vue application.
npm install wideangle-vuejs
- Enable and configure plugin.
import WideAnglePlugin from 'wideangle-vuejs'
app.use(WideAnglePlugin)
The Wide Angle Analytics plugin must be initialized with configuration object as there are required settings without defaults.
option | description | required | default | example |
---|---|---|---|---|
siteId | The Site ID from Wide Angle Site settings | ✅ | none | 8D27G3B9ACA01F4241 |
domain | Domain hosting the script, can be found in Wide Angle Analytics Site settings | ✅ | none | stats.wideangle.co |
fingerprint | Should script use browser fingerprinting; this might require collecting consent depeing on the applicable laws | ❌ | false | true |
suppressDnt | Should script ingore Do Not Track browser setting. If not enabled, not events will be sent if user's browser has DNT enabled | ❌ | false | true |
includeParams | An array of query parameters that can be passed as part of tracking event. By default only utm_* and ref parameters are passed in the event |
❌ | [] |
['sessionId', 'offset'] |
excludePaths | An array of URL paths that should not trigger default events such as page view, page leave | ❌ | [] |
['^/wp-admin/.*', ] |
ignoreHash | If enabled, change in the URL fragment will not trigger page view event | ❌ | false | true |
consentMarker | Cookie (with or without) value which present implies consent and absence lack its lack | ❌ | n/a | WAA_CONSENT=true |
You will find more details about these settings in Wide Angle Analytics documentation.
Example:
import WideAngle from 'wideangle-vue'
const app = createApp(App);
app.use(WideAngle, {
siteId: "8D27G3B9ACA01F4241",
domain: "stats.example.com",
fingerprint: true,
suppressDnt: true
});
The Wide Angle Analytics provides an instance of waa
which can be then injected to your component.
import { inject } from 'vue'
const waa = inject('waa');
You will find a fully functional example in this repository.
No action necessary. The tracker script automatically issues Page View and Page Leave events.
Wide Angle supports three specialized events:
- clicks
- downloads
- custom actions
Site has to have these event enable in Wide Angle Analytics configuration prior to usage. Otherwise the tracker script will not sent these events. Consult official documentation regarding how to enable event handling.
Currently Click Events are emitted automatically based on element data attributes.
Depending on the configured mode, the Download Event will fire automatically when either:
- a file with recognized extension is being downloaded, or
- when a link is marked with
data-waa-name
attribute.
Custom action are the most flexible and can be triggered directly from Vue components. As such their usage is not limitted due to Shadow DOM.
Example:
<template>
<button @click="sendEvent()">Send Event</button>
</template>
<script setup>
import { inject } from 'vue'
const waa = inject('waa');
const sendEvent = async () => {
const params = {
session: 'cjhw92nf9aq',
cohort: 'c1233'
}
waa.value.dispatchEvent('interest', params);
}
</script>
By default, Wide Angle Analytics does nore require consent thanks to its privacy-first, anonymous tracking and principaled approached to compliance.
However, you have additional toggles should you wish to control consent, either in Opt-In or Opt-Out mode.
If the visitors browsers has DoNotTrack
setting enabled in the browser, it will be understood as opt-out and not tracking events will be issued.
You website can't overwrite this behaviour by specifying suppressDnt
setting.
app.use(WideAngle, {
siteId: "8D27G3B9ACA01F4241",
suppressDnt: true
});
## Opt-In or Opt-Out based on Cookie
Wide Angle can be configure to handle presence of a cookie, or a cookie with specific value, as an implicit consent. Lack of the cookie will be handled as implicit opt-out.
Example configuration with cookie marker, expecting cookie name WAA_CONSENT
with value true
:
app.use(WideAngle, {
siteId: "8D27G3B9ACA01F4241",
consentMarker: "WAA_CONSENT=true"
});
The Wide Angle serving offers two additional methods, which allow for recording tracking consent:
-
recordConsent(subjectId: String): void
, and revokeConsent()
Calling above methods on waa
service will overwrite other consent mechanism (ie. DoNotTrack, and cookie marker).
Example usage:
<script setup>
import { inject } from 'vue'
const waa = inject('waa');
waa.value.recordConsent('FHJ44111');
</script>