@skyanalytics/vue3
v1.1.1
Published
SkyAnalytics Vue-3 is an adapter for [SkyAnalytics]
Downloads
93
Readme
SkyAnalytics Vue-3
SkyAnalytics Vue-3 is an adapter for SkyAnalytics that allows you to track your website's traffic and user behavior.
Installation
npm install @skyanalytics/vue3
Usage
import { createApp } from 'vue'
import analytics from '@skyanalytics/vue3'
const app = createApp({
// ...
})
app.use(analytics, {
key: 'source_key',
host: 'http://localhost:3000',
enabled: true // default is true
})
Directives
<button v-sk-analytics="{ event: 'click', data: { key: 'value' } }">Click me</button>
Methods
this.$skyAnalytics.event('event', { key: 'value' })
Composable
import { useAnalytics } from '@skyanalytics/vue3'
useAnalytics.event('event', { key: 'value' })
useAnalytics.navigate('page', { key: 'value' })
useAnalytics.metadata({ key: 'value' })
Vue-Router
import { createRouter } from 'vue-router'
import { useAnalytics } from '@skyanalytics/vue3'
const analytics = useAnalytics()
const router = createRouter({
// ...
})
router.beforeEach((to, from, next) => {
analytics.navigate(to.name)
next()
})
[!WARNING]
Use with caution, the methods$skyAnalytics
make sure that the instance is initialized and the plugin is enabled. Otherwise, it will throw an error.