Version upgrade together with consent API

This commit is contained in:
Jarek Rozanski 2025-01-27 22:56:20 +01:00
parent 787a1fd57f
commit e3dfded6b0
6 changed files with 83 additions and 23 deletions

View file

@ -6,7 +6,7 @@
[![Nuxt][nuxt-src]][nuxt-href] [![Nuxt][nuxt-src]][nuxt-href]
[![Wide Angle][wideangle-src]][wideangle-href] [![Wide Angle][wideangle-src]][wideangle-href]
![Wide Angle Analytics Large Logo](https://github.com/wideangleanalytics/wideangle-nuxt/assets/4896588/7efee4f1-d9e1-4b54-a5cd-257d13494f41) ![Wide Angle Analytics Large Logo](assets/full_logo_color_light_transparent.png)
# Wide Angle Analytics module for Nuxt # Wide Angle Analytics module for Nuxt
@ -52,10 +52,11 @@ option|description|required|default|example
siteId| The Site ID from the Wide Angle Site settings| :white_check_mark: | _none_ | 8D27G3B9ACA01F4241 siteId| The Site ID from the Wide Angle Site settings| :white_check_mark: | _none_ | 8D27G3B9ACA01F4241
domain| Domain hosting the script, can be found in Wide Angle Analytics Site settings | :x: | stats.wideangle.co | your.domain.com domain| Domain hosting the script, can be found in Wide Angle Analytics Site settings | :x: | stats.wideangle.co | your.domain.com
fingerprint | Should script use browser fingerprinting; this might require collecting consent depending on the applicable laws | :x: | false | true fingerprint | Should script use browser fingerprinting; this might require collecting consent depending on the applicable laws | :x: | false | true
supressDnt | Should script ingore Do Not Track browser setting. If not enabled, no events will be sent if user's browser has DNT enabled | :x: | false | true suppressDnt | Should script ingore Do Not Track browser setting. If not enabled, no events will be sent if user's browser has DNT enabled | :x: | 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 | :x: | `[]` | `['sessionId', 'offset']` 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 | :x: | `[]` | `['sessionId', 'offset']`
excludePaths | An array of URL paths that should not trigger default events such as page view, page leave | :x: | `[]` | `['^/wp-admin/.*', ]` excludePaths | An array of URL paths that should not trigger default events such as page view, page leave | :x: | `[]` | `['^/wp-admin/.*', ]`
ignoreHash | If enabled, a change in the URL fragment will not trigger page view event | :x: | false | true ignoreHash | If enabled, a change in the URL fragment will not trigger page view event | :x: | false | true
consentMarket | Name of cookie (with or without) which presence is treated as implied consent; when not defined, consent is not determined by cookie | :x: | n/a | `WAA_CONSENT=true`
You can find more details about these settings in the [Wide Angle Analytics documentation](https://wideangle.co/documentation/configure-site). You can find more details about these settings in the [Wide Angle Analytics documentation](https://wideangle.co/documentation/configure-site).
@ -72,10 +73,11 @@ export default defineNuxtConfig({
siteId: "8D27G3B9ACA01F4241", siteId: "8D27G3B9ACA01F4241",
domain: "your.domain.com", domain: "your.domain.com",
fingerprint: false, fingerprint: false,
supressDnt: true, suppressDnt: true,
includeParams: ['q', 'customerId'], includeParams: ['q', 'customerId'],
excludePaths: ['^/admin.*'], excludePaths: ['^/admin.*'],
ignoreHash: true ignoreHash: true,
consentMarker: `WAA_CONSENT=true`
} }
} }
} }
@ -88,7 +90,8 @@ export default defineNuxtConfig({
The Wide Angle Analytics provides an instance of `waa` which can be then injected to your component. The Wide Angle Analytics provides an instance of `waa` which can be then injected to your component.
```javascript ```javascript
useWaaEvent('purchase', {'basket_element': 'dress'}, {'basket_item_price': 123.44}); const waa = useWaa();
waa.dispatchEvent('purchase', {'basket_element': 'dress'}, {'basket_item_price': 123.44});
``` ```
You will find a fully functional example in this [repository](playground/app.vue). You will find a fully functional example in this [repository](playground/app.vue).
@ -129,13 +132,16 @@ Example:
</template> </template>
<script setup> <script setup>
import { useWaaEvent } from '#imports' import { useWaa } from '#imports'
const waa = useWaa();
const sendEvent = async () => { const sendEvent = async () => {
const params = { const params = {
session: 'cjhw92nf9aq', session: 'cjhw92nf9aq',
cohort: 'c1233' cohort: 'c1233'
} }
useWaaEvent('interest', params); waa.dispatchEvent('interest', params);
} }
</script> </script>
``` ```
@ -143,6 +149,61 @@ const sendEvent = async () => {
### Module Assets ### Module Assets
You can find a high-resolution Wide Angle Analytics logo and icon on our [media page](https://wideangle.co/media). You can find a high-resolution Wide Angle Analytics logo and icon on our [media page](https://wideangle.co/media).
# Recording consent
The Wide Angle Analytics, thanks to is privacy-first, anonymous approach to web traffic analytics does not requires consent by default.
However, we do offer multiple tools that support collecting consent should it be required in your use case.
## Opt-Out by default
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.
```javascript
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`:
```javascript
wideangle: {
siteId: "8D27G3B9ACA01F4241",
consentMarker: "WAA_CONSENT=true"
}
```
## Programmatic consent
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:
```vue
<script setup>
import { useWaa } from '#imports'
const waa = useWaa();
waa.recordConsent('FHJ44111');
</script>
```
<!-- Badges --> <!-- Badges -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

View file

@ -1,6 +1,6 @@
{ {
"name": "wideangle-nuxt", "name": "wideangle-nuxt",
"version": "1.2.2", "version": "2.0.0",
"description": "Wide Angle Analytics module for Nuxt", "description": "Wide Angle Analytics module for Nuxt",
"repository": "wideangleanalytics/wideangle-nuxt", "repository": "wideangleanalytics/wideangle-nuxt",
"author": "Wide Angle Analytics <developers@wideangle.co>", "author": "Wide Angle Analytics <developers@wideangle.co>",
@ -39,7 +39,7 @@
}, },
"dependencies": { "dependencies": {
"@nuxt/kit": "^3.13.2", "@nuxt/kit": "^3.13.2",
"wideangle-vuejs": "1.0.1", "wideangle-vuejs": "2.0.0",
"defu": "^6.1.2" "defu": "^6.1.2"
}, },
"devDependencies": { "devDependencies": {

View file

@ -8,10 +8,11 @@ export interface ModuleOptions {
siteId?: string siteId?: string
domain: string domain: string
fingerprint: boolean fingerprint: boolean
supressDnt: boolean suppressDnt: boolean
includeParams: string[] includeParams: string[]
excludePaths: string[] excludePaths: string[]
ignoreHash: boolean ignoreHash: boolean
consentMarker: string
} }
export default defineNuxtModule<ModuleOptions>({ export default defineNuxtModule<ModuleOptions>({
@ -25,10 +26,11 @@ export default defineNuxtModule<ModuleOptions>({
defaults: { defaults: {
domain: "stats.wideangle.co", domain: "stats.wideangle.co",
fingerprint: false, fingerprint: false,
supressDnt: false, suppressDnt: false,
includeParams: [], includeParams: [],
excludePaths: [], excludePaths: [],
ignoreHash: false ignoreHash: false,
consentMarker: null
}, },
setup (options, nuxt) { setup (options, nuxt) {
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url)) const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))

View file

@ -0,0 +1,8 @@
import { useNuxtApp } from '#imports';
function useWaa() {
const waa = useNuxtApp().$waa;
return waa.value;
}
export useWaa;

View file

@ -1,11 +0,0 @@
import { useNuxtApp } from '#imports';
export function useWaaEvent (name: string, params?: Record<string, any>, values?: Record<string, number>) {
const waa = useNuxtApp().$waa
console.debug(`[WAA] Attempting to send Wide Angle event: ${name}`);
if(waa && waa.value) {
waa.value.dispatchEvent(name, params, values);
} else {
console.debug("[WAA] Wide Angle Analytics is not yest initialized");
}
}