Skip to content

Easily log events to third party analytics providers

License

Notifications You must be signed in to change notification settings

spyfu/spyfu-vue-analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spyfu-vue-analytics

build status coverage dev dependencies npm MIT License

Installation

This plugin enables easy logging of events to third party analytics providers.

# install with yarn
yarn add spyfu-vue-analytics

# or install with npm
npm install spyfu-vue-analytics

Basic usage

Once the package is pulled in, you must instruct Vue to use it.

import Analytics from 'spyfu-vue-analytics';
import Vue from 'vue';

Vue.use(Analytics, {
    events: {
        userSignup: {
            google: {
                // define any additional data to pass to the
                // google handler when this event happens.
            },
        },
    },
    handlers: {
        google(eventName, eventConfig, payload) {
            // log event to google analytics
        },
    },
    logPageView(route) {
        // log page view event
    },
});

Finally, when an event you care about happens, use the $logEvent function to call your handlers.

// component.vue
export default {
    methods: {
        onUserSignup() {
            this.$logEvent('userSignup', payload);
        },
    },
};

About

Easily log events to third party analytics providers

Resources

License

Stars

Watchers

Forks

Packages

No packages published