@challenge-s2/sdk-analytics-challenge2
v0.1.64
Published
This is a SDK for Vue to send analytics to the server.
Downloads
129
Keywords
Readme
SDK Analytics For Vue
This is a SDK for Vue to send analytics to the server.
Installation
To install it, run one of the following commands in your project's root directory, depending on which package manager you use:
npm install @challenge-s2/sdk-analytics-challenge2
pnpm install @challenge-s2/sdk-analytics-challenge2
yarn add @challenge-s2/sdk-analytics-challenge2
Create a account in https://visionary-puppy-9927c5.netlify.app and get your app secret and your app ID.
Usage
Vue
To use it, you need to import the SDK and initialize it with your Secret key in main.js file:
import { tracker } from "@challenge-s2/sdk-analytics-challenge2/vue";
app.use(tracker, {
app_id: "<your app id>",
service: "web",
app_secret: "<your app secret>",
});
To track activity, use the track method in your component:
For click event:
<div v-track="'<tagName>'"> </div>
For mouseover event:
<div v-mouse="'<tagName>'"> </div>
For page tracking in your router file:
import { detectPage } from "@challenge-s2/sdk-analytics-challenge2/vue";
router.beforeEach((to, from, next) => {
detectPage(to.name);
next();
});
For visitor tracking when user login:
import { detectNewVisitor } from "@challenge-s2/sdk-analytics-challenge2/vue";
detectNewVisitor();
Server
To use it, you need to import the SDK and initialize it with your Secret key.
const tracker = require('@challenge-s2/sdk-analytics-challenge2/middleware');
app.use(tracker({
app_Id: '<your app id>',
service: 'api',
app_secret: '<your app secret>',
}))