npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-churnzero

v0.0.4

Published

ChurnZero plugin for Vue

Downloads

19

Readme

vue-churnzero

ChurnZero plugin for Vue

This plugin allows easily to bring ChurnZero script to your Vue application as well as it provides convenient methods to trigger events.

Main features:

  • Asynchronous script loading
  • Allows loading appKey, accountId and contactId asynchronously
  • Automatic router tracking
  • Vue directive for events
  • No dependencies

Requirements

Vue ^2.0.0

Install

npm install vue-churnzero

or

yarn add vue-churnzero

Getting started

After installing the package you can start using the plugin in your Vue application:

import Vue from 'vue'
import VueChurnZero from 'vue-churnzero';

Vue.use(VueChurnZero, {
    appKey: YOUR_APP_KEY,
    accountId: USER_ACCOUNT_ID,
    contactId: USER_CONTACT_ID,
});

Note: appKey, accountId and contactId can be promises. In this case, the plugin will start right after all the promises will be resolved. In order not to lose users' events in the meantime, the plugin collects users' event to storage and fires them later.

Once you registered the plugin, you can start tracking the events. There are multiple ways how you can do it.

Using instance method

In the component, you can access trackEvent method:

export default {
    name: 'my-component',

    methods: {
        track() {
            this.$cz.trackEvent('event name');
        }
    }
}

Please refer to the official ChurnZero documentation on trackEvent arguments. Note: you shouldn't send trackEvent as the first argument. The plugin does it for you. You just need to specify one required field eventName. description, quantity and customFields are all optional.

Using directive

Alternatively, you can use vue directive to achieve the same effect.

<template>
    <button v-cz="$cz.t(this, 'event name')">
        Click me
    </button>
</template>

t is a shorthand version of trackEvent. It binds trackEvent for you and allows you to save bytes in your components. Nevertheless, you still can use the full method if you'd like to:

<template>
    <button v-cz="$cz.trackEvent.bind(this, 'event name')">
        Click me
    </button>
</template>

Using commands

If you want to keep all of you tracking methods separately in one place, you can specify commands object while initializing the plugin.

import Vue from 'vue'
import VueChurnZero from 'vue-churnzero';

Vue.use(VueChurnZero, {
    appKey: YOUR_APP_KEY,
    accountId: USER_ACCOUNT_ID,
    contactId: USER_CONTACT_ID,
    commands: {
        trackButtonClick() {
            this.$cz.trackEvent('event name');
        }
    }
});

In this case, all you need is to specify the method name when using the directive:

<template>
    <button v-cz="'trackButtonClick'">
        Click me
    </button>
</template>

API

Coming soon